fozmo-3d-preview
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -36,4 +36,4 @@ import * as THREE from 'three'; | ||
loop(delta: number): void; | ||
destroy(): Promise<void>; | ||
destroy(): void; | ||
} | ||
export {}; |
@@ -96,3 +96,3 @@ import * as THREE from 'three'; | ||
} | ||
async destroy() { | ||
destroy() { | ||
HHConsole.info('销毁场景'); | ||
@@ -111,3 +111,2 @@ LoopManager.inst.setCurrentBaseLoop(undefined); | ||
this.scene.clear(); | ||
await Utils.delay(50); | ||
this.renderer.forceContextLoss(); | ||
@@ -114,0 +113,0 @@ this.renderer.domElement = null; |
@@ -35,2 +35,8 @@ import { ENV } from './framework/defines/HHGameTypes'; | ||
static Launch(config: LaunchConfig): Promise<void>; | ||
/** | ||
* 切换模型 | ||
* @param url 模型链接 | ||
*/ | ||
static changeModel(url: string): Promise<void>; | ||
static destroy(): void; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { SpaceManager } from './manager/SpaceManager'; | ||
import { LaunchSpace } from './root'; | ||
@@ -10,2 +11,12 @@ export class Fozmo3DPreview { | ||
} | ||
/** | ||
* 切换模型 | ||
* @param url 模型链接 | ||
*/ | ||
static async changeModel(url) { | ||
await SpaceManager.inst.changeModel(url); | ||
} | ||
static destroy() { | ||
SpaceManager.inst.destroy(); | ||
} | ||
} |
@@ -23,2 +23,4 @@ import { MainScene } from '../scenes/MainScene'; | ||
loadModle(url: string): Promise<void>; | ||
changeModel(url: string): Promise<void>; | ||
destroy(): void; | ||
} |
@@ -67,2 +67,12 @@ import { MainScene } from '../scenes/MainScene'; | ||
} | ||
async changeModel(url) { | ||
if (this._mainScene) { | ||
await this._mainScene.changeModel(url); | ||
} | ||
} | ||
destroy() { | ||
if (this._mainScene) { | ||
this._mainScene.destroy(); | ||
} | ||
} | ||
} |
@@ -30,2 +30,3 @@ import { BaseScene, BaseSceneConfig } from '../Base/BaseScene'; | ||
private handleUSDZ; | ||
changeModel(url: string): Promise<void>; | ||
private loadModel; | ||
@@ -38,2 +39,7 @@ private loadHDR; | ||
render(delta?: number): void; | ||
/** | ||
* 消除场景里的模型 | ||
*/ | ||
clear(): void; | ||
destroy(): void; | ||
} |
@@ -402,3 +402,16 @@ import { EEncryptExt, ENormalExt, ResLoaderManager } from './../manager/ResLoaderManager'; | ||
} | ||
async changeModel(url) { | ||
BPGameConfig.TestFile = url; | ||
await this.loadModel(url); | ||
const padding = 0.05; | ||
this._orbitControl.fitToBox(this._model, true, { | ||
cover: false, | ||
paddingBottom: padding, | ||
paddingLeft: padding, | ||
paddingRight: padding, | ||
paddingTop: padding, | ||
}); | ||
} | ||
async loadModel(url, rootPath = '') { | ||
this.clear(); | ||
let file = url; | ||
@@ -528,2 +541,26 @@ if (BPGameConfig.TestFile) { | ||
} | ||
/** | ||
* 消除场景里的模型 | ||
*/ | ||
clear() { | ||
if (this._model) { | ||
this.scene.remove(this._model); | ||
this._model.traverse((child) => { | ||
if (child instanceof THREE.Mesh) { | ||
child.geometry?.dispose(); | ||
Object.values(child.material).forEach((value) => { | ||
if (value && typeof value.dispose === "function") { | ||
value.dispose(); | ||
} | ||
}); | ||
} | ||
}); | ||
this._model = null; | ||
} | ||
} | ||
destroy() { | ||
this._orbitControl.dispose(); | ||
this._orbitControl = null; | ||
super.destroy(); | ||
} | ||
} |
{ | ||
"name": "fozmo-3d-preview", | ||
"version": "1.0.02", | ||
"version": "1.0.03", | ||
"description": "风之末 作品预览", | ||
@@ -5,0 +5,0 @@ "main": "lib/Fozmo3DPreview.js", |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
150528
4634