useThree.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. import * as THREE from 'three';
  2. // 导入轨道控制器
  3. import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
  4. import { CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer.js';
  5. import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
  6. import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
  7. // import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js';
  8. import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
  9. import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
  10. import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js';
  11. import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
  12. import Stats from 'three/examples/jsm/libs/stats.module.js';
  13. import { useModelStore } from '/@/store/modules/threejs';
  14. import TWEEN from 'three/examples/jsm/libs/tween.module.js';
  15. import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
  16. import { useGlobSetting } from '/@/hooks/setting';
  17. import { getList } from '@/views/vent/sys/resources/file.api';
  18. import { saveModel } from '/@/utils/threejs/util';
  19. const globSetting = useGlobSetting();
  20. const baseApiUrl = globSetting.domainUrl;
  21. // import * as dat from 'dat.gui';
  22. // const gui = new dat.GUI();
  23. // gui.domElement.style = 'position:absolute;top:10px;left:10px;z-index:99999999999999';
  24. class UseThree {
  25. stats: Stats | null = null; // 帧
  26. canvasContainer: HTMLCanvasElement | null; //canvas 容器
  27. CSSCanvasContainer: HTMLCanvasElement | null = null; // css canvas 容器
  28. camera: THREE.PerspectiveCamera | null = null; // 相机
  29. scene: THREE.Scene | null = null;
  30. renderer: THREE.WebGLRenderer | null = null;
  31. renderEnabled = true;
  32. css3dRender: CSS3DRenderer | null = null;
  33. css2dRender: CSS2DRenderer | null = null;
  34. orbitControls: OrbitControls | null = null;
  35. animationAction: THREE.AnimationAction | null = null;
  36. clock: THREE.Clock | null = new THREE.Clock(); // 计时器
  37. timeoutId: NodeJS.Timeout | null = null;
  38. animationId = 0;
  39. isRender = true;
  40. spriteText: THREE.Sprite | null = null;
  41. mouse = new THREE.Vector2();
  42. rayCaster: THREE.Raycaster | null = null;
  43. animations: THREE.AnimationClip[] = [];
  44. mixers: THREE.AnimationMixer[] = [];
  45. renderT = 1 / 40;
  46. timeS = 0;
  47. track: any = null;
  48. composer; //后期
  49. timeOut: NodeJS.Timeout | null = null; //
  50. textureMap = new Map<string, THREE.Texture>();
  51. constructor(canvasSelector, css3Canvas?, css2Canvas?) {
  52. this.canvasContainer = document.querySelector(canvasSelector);
  53. //初始化
  54. this.init(css3Canvas, css2Canvas);
  55. // this.animate();
  56. window.addEventListener('resize', this.resizeRenderer.bind(this));
  57. // 添加滚动事件,鼠标滚动模型执行动画
  58. // window.addEventListener('wheel', this.wheelRenderer.bind(this));
  59. // this.canvasContainer?.appendChild(gui.domElement);
  60. }
  61. init(css3Canvas?, css2Canvas?) {
  62. // 初始化场景
  63. this.initScene();
  64. // 初始化环境光
  65. // this.initLight();
  66. // 初始化相机
  67. this.initCamera();
  68. //初始化渲染器
  69. this.initRenderer();
  70. // 初始化控制器
  71. this.initControles();
  72. if (css3Canvas) {
  73. this.initCSS3Renderer(css3Canvas);
  74. }
  75. if (css2Canvas) {
  76. this.initCSS2Renderer(css2Canvas);
  77. }
  78. // this.setTestPlane();
  79. this.rayCaster = new THREE.Raycaster();
  80. // this.createStats();
  81. // this.removeSawtooth();
  82. }
  83. createStats() {
  84. this.stats = Stats();
  85. this.stats?.setMode(0);
  86. this.stats.domElement.style = 'position: absolute; top: 300px';
  87. this.canvasContainer?.appendChild(this.stats.domElement);
  88. }
  89. initScene() {
  90. this.scene = new THREE.Scene();
  91. // const axesHelper = new THREE.AxesHelper(100);
  92. // this.scene?.add(axesHelper);
  93. // const size = 1000;
  94. // const divisions = 10;
  95. // const gridHelper = new THREE.GridHelper(size, divisions);
  96. // this.scene?.add(gridHelper);
  97. }
  98. initLight() {
  99. // const light = new THREE.AmbientLight(0xffffff, 1);
  100. // light.position.set(0, 1000, 1000);
  101. // (this.scene as THREE.Scene).add(light);
  102. }
  103. initCamera() {
  104. // this.camera = new THREE.PerspectiveCamera(50, this.canvasContainer.clientWidth / this.canvasContainer.clientHeight, 0.0000001, 1000);
  105. if (!window['$camera']) {
  106. throw new Error('threejs摄像头初始化异常!');
  107. } else {
  108. this.camera = window['$camera'] as THREE.PerspectiveCamera;
  109. this.camera.layers.enableAll();
  110. if (this.canvasContainer) this.camera.aspect = this.canvasContainer.clientWidth / this.canvasContainer.clientHeight;
  111. this.camera.near = 0.0000001;
  112. this.camera.far = 1000;
  113. }
  114. //
  115. // const helper = new THREE.CameraHelper(this.camera);
  116. // this.scene?.add(helper);
  117. // gui.add(this.camera.position, 'x', 0.00001, 10000);
  118. // gui.add(this.camera.position, 'y', 0.00001, 10000);
  119. // gui.add(this.camera.position, 'z', 0.00001, 10000);
  120. // gui.add(this.camera, 'near', 0.01, 1).step(0.01);
  121. // gui.add(this.camera, 'far', 10, 100000);
  122. // gui.add(this.camera, 'fov', 0, 180);
  123. }
  124. initRenderer() {
  125. if (!window['$renderer']) {
  126. throw new Error('threejs渲染器初始化异常!');
  127. } else {
  128. this.renderer = window['$renderer'];
  129. if (this.canvasContainer) {
  130. this.renderer.toneMappingExposure = 1.0;
  131. this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
  132. // const gl = this.renderer?.getContext('webgl');
  133. // gl && gl.getExtension('WEBGL_lose_context')?.restoreContext();
  134. // this.renderer?.forceContextRestore()
  135. this.renderer?.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  136. this.canvasContainer.appendChild(this.renderer.domElement);
  137. }
  138. }
  139. }
  140. initCSS3Renderer(cssCanvas) {
  141. this.CSSCanvasContainer = document.querySelector(cssCanvas);
  142. if (this.CSSCanvasContainer) {
  143. this.css3dRender = new CSS3DRenderer() as CSS3DRenderer;
  144. this.css3dRender.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  145. this.CSSCanvasContainer?.appendChild(this.css3dRender.domElement);
  146. this.css3dRender.render(this.scene as THREE.Scene, this.camera as THREE.PerspectiveCamera);
  147. // this.css3dRender.domElement.style.pointerEvents = 'none';
  148. // this.orbitControls = new OrbitControls(this.camera as THREE.Camera, this.css3dRender?.domElement) as OrbitControls;
  149. // this.orbitControls.update();
  150. }
  151. }
  152. initCSS2Renderer(cssCanvas) {
  153. this.CSSCanvasContainer = document.querySelector(cssCanvas);
  154. if (this.CSSCanvasContainer) {
  155. this.css2dRender = new CSS2DRenderer();
  156. this.css2dRender.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  157. this.CSSCanvasContainer?.appendChild(this.css2dRender.domElement);
  158. this.css2dRender.render(this.scene as THREE.Scene, this.camera as THREE.PerspectiveCamera);
  159. // this.orbitControls = new OrbitControls(this.camera as THREE.Camera, this.css2dRender?.domElement) as OrbitControls;
  160. // this.orbitControls.update();
  161. // this.css2dRender.domElement.style.pointerEvents = 'none';
  162. }
  163. }
  164. initControles() {
  165. if (!window['$orbitControls']) {
  166. throw new Error('threejs控制器初始化异常!');
  167. } else {
  168. this.orbitControls = window['$orbitControls'];
  169. this.orbitControls.panSpeed = 1;
  170. this.orbitControls.rotateSpeed = 1;
  171. this.orbitControls.maxPolarAngle = Math.PI;
  172. this.orbitControls.minPolarAngle = 0;
  173. }
  174. // this.orbitControls = new OrbitControls(this.camera as THREE.Camera, this.renderer?.domElement) as OrbitControls;
  175. // this.orbitControls.update();
  176. // this.orbitControls.minDistance = 1;
  177. // this.orbitControls.maxDistance = 100;
  178. // this.orbitControls.maxDistance = true;
  179. }
  180. setGLTFModel(modalNames, group = null) {
  181. window['startTime'] = new Date().getTime();
  182. const modelStore = useModelStore();
  183. return new Promise(async (resolve, reject) => {
  184. try {
  185. const gltfLoader = new GLTFLoader();
  186. const dracoLoader = new DRACOLoader();
  187. dracoLoader.setDecoderPath('/model/draco/gltf/');
  188. dracoLoader.setDecoderConfig({ type: 'js' }); //使用兼容性强的draco_decoder.js解码器
  189. dracoLoader.preload();
  190. gltfLoader.setDRACOLoader(dracoLoader);
  191. const db = window['CustomDB'];
  192. const resolvePromise: Promise<any>[] = [];
  193. const modalNameArr = Object.prototype.toString.call(modalNames) === '[object Array]' ? modalNames : [modalNames];
  194. const len = modalNameArr.length;
  195. for (let i = 0; i < len; i++) {
  196. resolvePromise[i] = new Promise(async (childResolve, reject) => {
  197. try {
  198. // 解析模型
  199. const modalNameStr = modalNameArr[i];
  200. const data = modelStore.modelArr.get(modalNameStr) || null;
  201. let modalValue;
  202. if (!data) {
  203. const modalArr = await db.modal.where('modalName').equals(modalNameStr).toArray();
  204. if (modalArr.length > 0) {
  205. modalValue = modalArr[0].modalVal;
  206. }
  207. } else {
  208. modalValue = data.modalVal;
  209. }
  210. if (modalValue) {
  211. gltfLoader.parse(
  212. modalValue,
  213. '/model/glft/',
  214. (gltf) => {
  215. const object = gltf.scene;
  216. // setModalCenter(object);
  217. object.traverse((obj) => {
  218. if (obj instanceof THREE.Mesh) {
  219. obj.material.emissiveIntensity = 1;
  220. obj.material.emissiveMap = obj.material.map;
  221. obj.material.blending = THREE.CustomBlending;
  222. if (obj.material.opacity < 1) {
  223. obj.material.transparent = true;
  224. }
  225. if (obj.material.map) {
  226. obj.material.map.colorSpace = THREE.SRGBColorSpace;
  227. obj.material.map.flipY = false;
  228. obj.material.map.anisotropy = 1;
  229. }
  230. if (obj.material.emissiveMap) {
  231. obj.material.emissiveMap.colorSpace = THREE.SRGBColorSpace;
  232. obj.material.emissiveMap.flipY = false;
  233. }
  234. if (obj.material.map || obj.material.emissiveMap) {
  235. obj.material.needsUpdate = true;
  236. }
  237. // if (envMap) {
  238. // obj.material.envMap = envMap;
  239. // obj.material.envMapIntensity = 1;
  240. // }
  241. // obj.renderOrder = 1;
  242. }
  243. });
  244. object.animations = gltf.animations;
  245. object.name = modalNameStr;
  246. group?.add(object);
  247. childResolve(object);
  248. },
  249. (err) => {
  250. console.log(err);
  251. }
  252. );
  253. } else {
  254. // 开启线程下载
  255. console.log('需要开启线程下载模型资源。。。。。');
  256. const result = (await getList({ fileName: modalNameStr })) || [];
  257. const file = result['records'][0];
  258. if (file && file.path) {
  259. gltfLoader.load(`${baseApiUrl}/sys/common/static/${file.path}`, async (glft) => {
  260. if (glft) {
  261. const object = glft.scene;
  262. object.name = modalNameStr;
  263. if (glft.animations.length > 0) {
  264. object.animations = glft.animations;
  265. }
  266. group?.add(object);
  267. childResolve(object);
  268. const modalArr = await db.modal.where('modalName').equals(modalNameStr).toArray();
  269. if (modalArr.length < 1) {
  270. saveModel(modalNameStr, file.path, file.version);
  271. }
  272. }
  273. });
  274. }
  275. }
  276. } catch (error) {
  277. console.log(error);
  278. reject();
  279. }
  280. });
  281. }
  282. Promise.all(resolvePromise).then((objects) => {
  283. dracoLoader.dispose();
  284. resolve(objects);
  285. });
  286. } catch (error) {
  287. reject('加载模型出错');
  288. }
  289. });
  290. }
  291. // setFBXModel(modalNames, group = null) {
  292. // window['startTime'] = new Date().getTime();
  293. // const modelStore = useModelStore();
  294. // return new Promise(async (resolve, reject) => {
  295. // try {
  296. // const fbxLoader = new FBXLoader();
  297. // fbxLoader.setPath('/model/fbx/');
  298. // const db = window['CustomDB'];
  299. // const resolvePromise: Promise<any>[] = [];
  300. // let modalNameArr = Object.prototype.toString.call(modalNames) === '[object Array]' ? modalNames : [modalNames];
  301. // let len = modalNameArr.length;
  302. // for (let i = 0; i < len; i++) {
  303. // resolvePromise[i] = new Promise(async (childResolve, reject) => {
  304. // try {
  305. // // 解析模型
  306. // let modalValue;
  307. // const modalNameStr = modalNameArr[i];
  308. // let data = modelStore.modelArr.get(modalNameStr) || null;
  309. // if (!data) {
  310. // const modalArr = await db.modal.where('modalName').equals(modalNameStr).toArray();
  311. // if (modalArr.length > 0) modalValue = modalArr[0].modalVal;
  312. // } else {
  313. // modalValue = data.modalVal;
  314. // }
  315. // if (modalValue) {
  316. // const object = fbxLoader.parse(modalValue, '/model/fbx/');
  317. // // const object = fbx.scene;
  318. // // setModalCenter(object);
  319. // if (object) {
  320. // object.traverse((obj) => {
  321. // if (obj instanceof THREE.Mesh) {
  322. // obj.material.emissiveIntensity = 1;
  323. // obj.material.emissiveMap = obj.material.map;
  324. // obj.material.blending = THREE.CustomBlending;
  325. // if (obj.material.opacity < 1) {
  326. // obj.material.transparent = true;
  327. // }
  328. // if (obj.material.map) {
  329. // obj.material.map.encoding = THREE.sRGBEncoding;
  330. // obj.material.map.flipY = false;
  331. // obj.material.map.anisotropy = 1;
  332. // }
  333. // if (obj.material.emissiveMap) {
  334. // obj.material.emissiveMap.encoding = THREE.sRGBEncoding;
  335. // obj.material.emissiveMap.flipY = false;
  336. // }
  337. // if (obj.material.map || obj.material.emissiveMap) {
  338. // obj.material.needsUpdate = true;
  339. // }
  340. // // if (envMap) {
  341. // // obj.material.envMap = envMap;
  342. // // obj.material.envMapIntensity = 1;
  343. // // }
  344. // // obj.renderOrder = 1;
  345. // }
  346. // });
  347. // object.animations = object.animations;
  348. // object.name = modalNameStr;
  349. // group?.add(object);
  350. // childResolve(object);
  351. // }
  352. // }
  353. // } catch (error) {
  354. // console.log(error);
  355. // reject();
  356. // }
  357. // });
  358. // }
  359. // Promise.all(resolvePromise).then((objects) => {
  360. // resolve(objects);
  361. // });
  362. // } catch (error) {
  363. // reject('加载模型出错');
  364. // }
  365. // });
  366. // }
  367. setTestPlane() {
  368. const plane = new THREE.Mesh(new THREE.PlaneGeometry(10, 10), new THREE.MeshPhongMaterial({ color: 0x999999, specular: 0x101010 }));
  369. plane.rotation.x = -Math.PI / 2;
  370. plane.position.y = 0.03;
  371. plane.receiveShadow = true;
  372. this.scene?.add(plane);
  373. }
  374. removeSawtooth() {
  375. this.composer = new EffectComposer(this.renderer as THREE.WebGLRenderer);
  376. const FXAAShaderPass = new ShaderPass(FXAAShader);
  377. FXAAShaderPass.uniforms['resolution'].value.set(1 / this.canvasContainer.clientWidth, 1 / this.canvasContainer.clientHeight);
  378. FXAAShaderPass.renderToScreen = true;
  379. this.composer.addPass(FXAAShaderPass);
  380. }
  381. /* 场景环境背景 */
  382. setEnvMap(hdr) {
  383. if (!this.scene) return;
  384. // (this.scene as THREE.Scene).environment
  385. new RGBELoader().setPath('/model/hdr/').load(hdr + '.hdr', (texture) => {
  386. texture.colorSpace = THREE.SRGBColorSpace;
  387. texture.mapping = THREE.EquirectangularReflectionMapping;
  388. if (this.scene) (this.scene as THREE.Scene).environment = texture;
  389. texture.dispose();
  390. });
  391. }
  392. render() {
  393. this.startAnimation();
  394. this.orbitControls?.update();
  395. this.camera?.updateMatrixWorld();
  396. // this.composer?.render();
  397. this.css3dRender?.render(this.scene as THREE.Scene, this.camera as THREE.PerspectiveCamera);
  398. this.css2dRender?.render(this.scene as THREE.Scene, this.camera as THREE.PerspectiveCamera);
  399. this.renderer?.render(this.scene as THREE.Object3D, this.camera as THREE.Camera);
  400. }
  401. timeRender() {
  402. //设置为可渲染状态
  403. this.renderEnabled = true;
  404. //清除上次的延迟器
  405. if (this.timeOut) {
  406. clearTimeout(this.timeOut);
  407. }
  408. this.timeOut = setTimeout(() => {
  409. this.renderEnabled = false;
  410. }, 3000);
  411. }
  412. /* 漫游 */
  413. startMY() {}
  414. /* 初始动画 */
  415. startAnimation() {}
  416. renderAnimationScene() {}
  417. animate() {
  418. if (this.isRender) {
  419. this.animationId = requestAnimationFrame(this.animate.bind(this));
  420. const T = this.clock?.getDelta() || 0;
  421. this.timeS = this.timeS + T;
  422. if (this.timeS > this.renderT) {
  423. this.renderAnimationScene();
  424. if (this.renderEnabled) {
  425. this.render();
  426. }
  427. this.stats?.update();
  428. this.timeS = 0;
  429. }
  430. // this.stats?.update();
  431. // // TWEEN.update();
  432. // // this.renderAnimationScene();
  433. // if (this.renderEnabled) {
  434. // this.render();
  435. // }
  436. }
  437. }
  438. resizeRenderer() {
  439. // 更新相机比例
  440. if (this.camera) {
  441. (this.camera as THREE.PerspectiveCamera).aspect = this.canvasContainer.clientWidth / this.canvasContainer.clientHeight;
  442. // 刷新相机矩阵
  443. this.camera?.updateProjectionMatrix();
  444. }
  445. // 设置场景尺寸
  446. this.renderer?.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  447. this.css3dRender?.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  448. this.css2dRender?.setSize(this.canvasContainer.clientWidth, this.canvasContainer.clientHeight);
  449. }
  450. wheelRenderer(e: WheelEvent) {
  451. const timeScale = e.deltaY > 0 ? 1 : -1;
  452. this.animationAction?.setEffectiveTimeScale(timeScale);
  453. (this.animationAction as THREE.AnimationAction).paused = false;
  454. this.animationAction?.play();
  455. if (this.timeoutId) {
  456. clearTimeout(this.timeoutId);
  457. }
  458. this.timeoutId = setTimeout(() => {
  459. this.animationAction?.halt(0.5);
  460. }, 500);
  461. }
  462. clearMesh(item) {
  463. item.geometry?.dispose();
  464. if (item.material) {
  465. const material = item.material;
  466. for (const key of Object.keys(material)) {
  467. const value = material[key];
  468. // if (value && typeof value === 'object' && 'minFilter' in value) {
  469. // // this.textureMap.set(value.uuid, value);
  470. // value.dispose();
  471. // }
  472. if (value && typeof value === 'object' && value['dispose'] && typeof value['dispose'] === 'function') {
  473. value.dispose();
  474. }
  475. }
  476. material.dispose();
  477. }
  478. if (item.texture) {
  479. item.texture.dispose();
  480. }
  481. }
  482. clearGroup(group) {
  483. const removeObj = (obj) => {
  484. if (obj && obj?.children && obj?.children.length > 0) {
  485. for (let i = obj?.children.length - 1; i >= 0; i--) {
  486. const item = obj?.children[i];
  487. if (item && item.children && item.children.length > 0) {
  488. removeObj(item);
  489. item?.clear();
  490. } else {
  491. if (item) {
  492. if (item.parent) item.parent.remove(item);
  493. this.clearMesh(item);
  494. item.clear();
  495. }
  496. }
  497. }
  498. }
  499. };
  500. removeObj(group);
  501. }
  502. clearScene() {
  503. this.clearGroup(this.scene);
  504. // console.log('场景纹理数量----------->', this.textureMap.size);
  505. this.textureMap.forEach((texture) => {
  506. texture?.dispose();
  507. });
  508. this.textureMap.clear();
  509. }
  510. destroy() {
  511. TWEEN.getAll().forEach((item) => {
  512. item.stop();
  513. });
  514. TWEEN.removeAll();
  515. this.isRender = false;
  516. cancelAnimationFrame(this.animationId);
  517. this.clearScene();
  518. window.removeEventListener('resize', this.resizeRenderer);
  519. // this.orbitControls?.dispose();
  520. // this.scene?.environment?.dispose();
  521. this.scene?.clear();
  522. this.renderer?.dispose();
  523. this.renderer?.getRenderTarget()?.dispose();
  524. if (this.renderer && this.canvasContainer) this.canvasContainer.innerHTML = '';
  525. if (this.CSSCanvasContainer && this.css3dRender) this.CSSCanvasContainer.innerHTML = '';
  526. // if (this.renderer) this.renderer.domElement = null;
  527. this.renderer?.clear();
  528. if (this.css3dRender) this.css3dRender.domElement = null;
  529. if (this.css2dRender) this.css2dRender.domElement = null;
  530. if (this.canvasContainer) this.canvasContainer.innerHTML = '';
  531. if (this.CSSCanvasContainer) this.CSSCanvasContainer.innerHTML = '';
  532. this.camera = null;
  533. this.orbitControls = null;
  534. this.renderer = null;
  535. this.stats = null;
  536. this.scene = null;
  537. this.css3dRender = null;
  538. this.css2dRender = null;
  539. THREE.Cache.clear();
  540. console.log('场景销毁后信息----------->', window['$renderer']?.info, this.scene);
  541. }
  542. }
  543. export default UseThree;