chore(editor): warm up circular water pool after viewer init
This commit is contained in:
parent
d7c36e31f7
commit
e62f2b54d5
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {onMounted, ref, nextTick, onBeforeUnmount} from 'vue';
|
import {onMounted, ref, nextTick, onBeforeUnmount} from 'vue';
|
||||||
import {App,Viewer,Hooks} from "@astral3d/engine";
|
import {App,Viewer,Hooks,WaterPool} from "@astral3d/engine";
|
||||||
import Toolbar from "./Toolbar.vue";
|
import Toolbar from "./Toolbar.vue";
|
||||||
import PathDrawingOverlay from "./PathDrawingOverlay.vue";
|
import PathDrawingOverlay from "./PathDrawingOverlay.vue";
|
||||||
import {useGlobalConfigStore} from "@/store/modules/globalConfig";
|
import {useGlobalConfigStore} from "@/store/modules/globalConfig";
|
||||||
@ -30,6 +30,43 @@ const pluginStore = usePluginStore();
|
|||||||
|
|
||||||
const viewportRef = ref();
|
const viewportRef = ref();
|
||||||
|
|
||||||
|
function bootstrapWaterPoolWarmup(viewer: Viewer) {
|
||||||
|
const warmupPool = new WaterPool({
|
||||||
|
sky: viewer.scene.environment,
|
||||||
|
name: '__water_pool_warmup__',
|
||||||
|
type: 'cylinder',
|
||||||
|
light: [0.7, 1, -0.3],
|
||||||
|
diameter: 5,
|
||||||
|
height: 5,
|
||||||
|
wallMode: 'none',
|
||||||
|
wallOpacity: 0,
|
||||||
|
useSceneRefraction: 1,
|
||||||
|
surfaceTransmittance: 0.6,
|
||||||
|
normalStrength: 0.5,
|
||||||
|
refractionStrength: 0.035,
|
||||||
|
});
|
||||||
|
|
||||||
|
warmupPool.visible = false;
|
||||||
|
|
||||||
|
// Use scene.add/remove directly to avoid objectAdded/objectRemoved signals and scene tree refresh.
|
||||||
|
viewer.scene.add(warmupPool);
|
||||||
|
|
||||||
|
const removeWarmupPool = () => {
|
||||||
|
if (warmupPool.parent) {
|
||||||
|
warmupPool.parent.remove(warmupPool);
|
||||||
|
}
|
||||||
|
warmupPool.dispose?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
const loaded = (warmupPool as any).loaded;
|
||||||
|
if (loaded && typeof loaded.then === 'function') {
|
||||||
|
loaded.finally(removeWarmupPool);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeWarmupPool();
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
App.setConfig({
|
App.setConfig({
|
||||||
theme: globalStore.theme.replace("Theme", ""),
|
theme: globalStore.theme.replace("Theme", ""),
|
||||||
@ -48,6 +85,8 @@ onMounted(async () => {
|
|||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
|
bootstrapWaterPoolWarmup(window.viewer);
|
||||||
|
|
||||||
// 添加astral engine内置插件并监听插件注册
|
// 添加astral engine内置插件并监听插件注册
|
||||||
pluginStore.setPlugins(Array.from(window.viewer.modules.plugin.plugins.values()));
|
pluginStore.setPlugins(Array.from(window.viewer.modules.plugin.plugins.values()));
|
||||||
Hooks.useAddSignal("pluginInstall",pluginStore.addPlugin);
|
Hooks.useAddSignal("pluginInstall",pluginStore.addPlugin);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user