新增场景释放机制和Dispose方法
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
</CfFlex>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, useTemplateRef } from 'vue';
|
||||
import { onBeforeUnmount, onMounted, onUnmounted, ref, useTemplateRef } from 'vue';
|
||||
import MaterialAdjuster from './MaterialAdjuster.vue';
|
||||
import { useScene } from '../stores/sceneStore';
|
||||
import CfFlex from './CfFlex.vue';
|
||||
@@ -21,15 +21,26 @@ const textureSrc = ref(config.textureSrc);
|
||||
|
||||
// 禁用右键菜单
|
||||
document.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||
|
||||
onMounted(() => {
|
||||
scene.Initial(container.value);
|
||||
eventbus.Subscribe('submit', () => adjusterRef.value.Upload());
|
||||
eventbus.Subscribe('update-texture', () => {
|
||||
textureSrc.value = config.textureSrc
|
||||
});
|
||||
eventbus.Subscribe('submit', HandleUpload);
|
||||
eventbus.Subscribe('update-texture', HandleChangeTexture);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
eventbus.Unsubscribe('submit', HandleUpload);
|
||||
eventbus.Unsubscribe('update-texture', HandleChangeTexture);
|
||||
scene.Dispose();
|
||||
});
|
||||
|
||||
function HandleUpload() {
|
||||
adjusterRef.value.Upload();
|
||||
}
|
||||
|
||||
function HandleChangeTexture() {
|
||||
textureSrc.value = config.textureSrc;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
Reference in New Issue
Block a user