@inweb/viewer-three 27.6.4 → 27.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/components/RoomEnvironmentComponent.js +1 -0
- package/dist/extensions/components/RoomEnvironmentComponent.js.map +1 -1
- package/dist/extensions/components/RoomEnvironmentComponent.min.js +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.js +127 -131
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.js +127 -131
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
- package/dist/extensions/loaders/IFCXLoader.js +10 -9
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
- package/dist/extensions/loaders/PotreeLoader.js +5 -5
- package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
- package/dist/viewer-three.js +5368 -4815
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +5 -5
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +10 -10
- package/src/Viewer/components/SectionsComponent.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomEnvironmentComponent.js","sources":["../../../../../node_modules/three/examples/jsm/environments/RoomEnvironment.js","../../../extensions/components/RoomEnvironmentComponent.ts"],"sourcesContent":["import {\n \tBackSide,\n \tBoxGeometry,\n \tInstancedMesh,\n \tMesh,\n\tMeshLambertMaterial,\n \tMeshStandardMaterial,\n \tPointLight,\n \tScene,\n \tObject3D,\n} from 'three';\n\n/**\n * This class represents a scene with a basic room setup that can be used as\n * input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents the room's\n * lighting and can be used for Image Based Lighting by assigning it to {@link Scene#environment}\n * or directly as an environment map to PBR materials.\n *\n * The implementation is based on the [EnvironmentScene](https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts)\n * component from the `model-viewer` project.\n *\n * ```js\n * const environment = new RoomEnvironment();\n * const pmremGenerator = new THREE.PMREMGenerator( renderer );\n *\n * const envMap = pmremGenerator.fromScene( environment ).texture;\n * scene.environment = envMap;\n * ```\n *\n * @augments Scene\n * @three_import import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';\n */\nclass RoomEnvironment extends Scene {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.name = 'RoomEnvironment';\n\n\t\tconst geometry = new BoxGeometry();\n\t\tgeometry.deleteAttribute( 'uv' );\n\n\t\tconst roomMaterial = new MeshStandardMaterial( { side: BackSide } );\n\t\tconst boxMaterial = new MeshStandardMaterial();\n\n\t\tconst mainLight = new PointLight( 0xffffff, 900, 28, 2 );\n\t\tmainLight.position.set( 0.418, 16.199, 0.300 );\n\t\tthis.add( mainLight );\n\n\t\tconst room = new Mesh( geometry, roomMaterial );\n\t\troom.position.set( - 0.757, 13.219, 0.717 );\n\t\troom.scale.set( 31.713, 28.305, 28.591 );\n\t\tthis.add( room );\n\n\t\tconst boxes = new InstancedMesh( geometry, boxMaterial, 6 );\n\t\tconst transform = new Object3D();\n\n\t\t// box1\n\t\ttransform.position.set( - 10.906, 2.009, 1.846 );\n\t\ttransform.rotation.set( 0, - 0.195, 0 );\n\t\ttransform.scale.set( 2.328, 7.905, 4.651 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 0, transform.matrix );\n\n\t\t// box2\n\t\ttransform.position.set( - 5.607, - 0.754, - 0.758 );\n\t\ttransform.rotation.set( 0, 0.994, 0 );\n\t\ttransform.scale.set( 1.970, 1.534, 3.955 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 1, transform.matrix );\n\n\t\t// box3\n\t\ttransform.position.set( 6.167, 0.857, 7.803 );\n\t\ttransform.rotation.set( 0, 0.561, 0 );\n\t\ttransform.scale.set( 3.927, 6.285, 3.687 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 2, transform.matrix );\n\n\t\t// box4\n\t\ttransform.position.set( - 2.017, 0.018, 6.124 );\n\t\ttransform.rotation.set( 0, 0.333, 0 );\n\t\ttransform.scale.set( 2.002, 4.566, 2.064 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 3, transform.matrix );\n\n\t\t// box5\n\t\ttransform.position.set( 2.291, - 0.756, - 2.621 );\n\t\ttransform.rotation.set( 0, - 0.286, 0 );\n\t\ttransform.scale.set( 1.546, 1.552, 1.496 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 4, transform.matrix );\n\n\t\t// box6\n\t\ttransform.position.set( - 2.193, - 0.369, - 5.547 );\n\t\ttransform.rotation.set( 0, 0.516, 0 );\n\t\ttransform.scale.set( 3.875, 3.487, 2.986 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 5, transform.matrix );\n\n\t\tthis.add( boxes );\n\n\n\t\t// -x right\n\t\tconst light1 = new Mesh( geometry, createAreaLightMaterial( 50 ) );\n\t\tlight1.position.set( - 16.116, 14.37, 8.208 );\n\t\tlight1.scale.set( 0.1, 2.428, 2.739 );\n\t\tthis.add( light1 );\n\n\t\t// -x left\n\t\tconst light2 = new Mesh( geometry, createAreaLightMaterial( 50 ) );\n\t\tlight2.position.set( - 16.109, 18.021, - 8.207 );\n\t\tlight2.scale.set( 0.1, 2.425, 2.751 );\n\t\tthis.add( light2 );\n\n\t\t// +x\n\t\tconst light3 = new Mesh( geometry, createAreaLightMaterial( 17 ) );\n\t\tlight3.position.set( 14.904, 12.198, - 1.832 );\n\t\tlight3.scale.set( 0.15, 4.265, 6.331 );\n\t\tthis.add( light3 );\n\n\t\t// +z\n\t\tconst light4 = new Mesh( geometry, createAreaLightMaterial( 43 ) );\n\t\tlight4.position.set( - 0.462, 8.89, 14.520 );\n\t\tlight4.scale.set( 4.38, 5.441, 0.088 );\n\t\tthis.add( light4 );\n\n\t\t// -z\n\t\tconst light5 = new Mesh( geometry, createAreaLightMaterial( 20 ) );\n\t\tlight5.position.set( 3.235, 11.486, - 12.541 );\n\t\tlight5.scale.set( 2.5, 2.0, 0.1 );\n\t\tthis.add( light5 );\n\n\t\t// +y\n\t\tconst light6 = new Mesh( geometry, createAreaLightMaterial( 100 ) );\n\t\tlight6.position.set( 0.0, 20.0, 0.0 );\n\t\tlight6.scale.set( 1.0, 0.1, 1.0 );\n\t\tthis.add( light6 );\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the environment is no longer required.\n\t */\n\tdispose() {\n\n\t\tconst resources = new Set();\n\n\t\tthis.traverse( ( object ) => {\n\n\t\t\tif ( object.isMesh ) {\n\n\t\t\t\tresources.add( object.geometry );\n\t\t\t\tresources.add( object.material );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tfor ( const resource of resources ) {\n\n\t\t\tresource.dispose();\n\n\t\t}\n\n\t}\n\n}\n\nfunction createAreaLightMaterial( intensity ) {\n\n\t// create an emissive-only material. see #31348\n\tconst material = new MeshLambertMaterial( {\n\t\tcolor: 0x000000,\n\t\temissive: 0xffffff,\n\t\temissiveIntensity: intensity\n\t} );\n\n\treturn material;\n\n}\n\nexport { RoomEnvironment };\n","///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2026, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { PMREMGenerator } from \"three\";\nimport { RoomEnvironment } from \"three/examples/jsm/environments/RoomEnvironment.js\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass RoomEnvironmentComponent implements IComponent {\n protected viewer: Viewer;\n\n constructor(viewer: Viewer) {\n this.viewer = viewer;\n\n const environment = new RoomEnvironment();\n const pmremGenerator = new PMREMGenerator(this.viewer.renderer);\n\n this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;\n\n environment.dispose();\n }\n\n dispose() {\n this.viewer.scene.environment = undefined;\n }\n}\n\ncomponents.registerComponent(\"LightComponent\", (viewer) => new RoomEnvironmentComponent(viewer));\n"],"names":["Scene","BoxGeometry","MeshStandardMaterial","BackSide","PointLight","Mesh","InstancedMesh","Object3D","MeshLambertMaterial","PMREMGenerator","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCA,MAAM,eAAe,SAASA,WAAK,CAAC;CAEpC,CAAC,WAAW,GAAG;CAEf,EAAE,KAAK,EAAE;CAET,EAAE,IAAI,CAAC,IAAI,GAAG,iBAAiB;CAE/B,EAAE,MAAM,QAAQ,GAAG,IAAIC,iBAAW,EAAE;CACpC,EAAE,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE;CAElC,EAAE,MAAM,YAAY,GAAG,IAAIC,0BAAoB,EAAE,EAAE,IAAI,EAAEC,cAAQ,EAAE,EAAE;CACrE,EAAE,MAAM,WAAW,GAAG,IAAID,0BAAoB,EAAE;CAEhD,EAAE,MAAM,SAAS,GAAG,IAAIE,gBAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE;CAC1D,EAAE,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;CAChD,EAAE,IAAI,CAAC,GAAG,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,CAAC,EAAE;CAEL,EAAE,MAAM,MAAM,QAAQ,IAAI,SAAS,GAAG;CAEtC,GAAG,QAAQ,CAAC,OAAO,EAAE;CAErB,EAAE;CAEF,CAAC;CAED;CAEA,SAAS,uBAAuB,EAAE,SAAS,GAAG;CAG9C,CAAC,MAAM,QAAQ,GAAG,IAAIG,yBAAmB,EAAE;CAC3C,EAAE,KAAK,EAAE,QAAQ;CACjB,EAAE,QAAQ,EAAE,QAAQ;CACpB,EAAE,iBAAiB,EAAE;CACrB,EAAE,EAAE;CAEJ,CAAC,OAAO,QAAQ;CAEhB;;CC1JA,MAAM,wBAAwB,CAAA;CAG5B,IAAA,WAAA,CAAY,MAAc,EAAA;CACxB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;CAEpB,QAAA,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE;SACzC,MAAM,cAAc,GAAG,IAAIC,oBAAc,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;CAE/D,QAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO;SAE7E,WAAW,CAAC,OAAO,EAAE;KACvB;KAEA,OAAO,GAAA;SACL,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS;KAC3C;CACD;AAEDC,uBAAU,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,CAAC,MAAM,KAAK,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"RoomEnvironmentComponent.js","sources":["../../../../../node_modules/three/examples/jsm/environments/RoomEnvironment.js","../../../extensions/components/RoomEnvironmentComponent.ts"],"sourcesContent":["import {\n \tBackSide,\n \tBoxGeometry,\n \tInstancedMesh,\n \tMesh,\n\tMeshLambertMaterial,\n \tMeshStandardMaterial,\n \tPointLight,\n \tScene,\n \tObject3D,\n} from 'three';\n\n/**\n * This class represents a scene with a basic room setup that can be used as\n * input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents the room's\n * lighting and can be used for Image Based Lighting by assigning it to {@link Scene#environment}\n * or directly as an environment map to PBR materials.\n *\n * The implementation is based on the [EnvironmentScene](https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts)\n * component from the `model-viewer` project.\n *\n * ```js\n * const environment = new RoomEnvironment();\n * const pmremGenerator = new THREE.PMREMGenerator( renderer );\n *\n * const envMap = pmremGenerator.fromScene( environment ).texture;\n * scene.environment = envMap;\n * ```\n *\n * @augments Scene\n * @three_import import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';\n */\nclass RoomEnvironment extends Scene {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.name = 'RoomEnvironment';\n\t\tthis.position.y = - 3.5;\n\n\t\tconst geometry = new BoxGeometry();\n\t\tgeometry.deleteAttribute( 'uv' );\n\n\t\tconst roomMaterial = new MeshStandardMaterial( { side: BackSide } );\n\t\tconst boxMaterial = new MeshStandardMaterial();\n\n\t\tconst mainLight = new PointLight( 0xffffff, 900, 28, 2 );\n\t\tmainLight.position.set( 0.418, 16.199, 0.300 );\n\t\tthis.add( mainLight );\n\n\t\tconst room = new Mesh( geometry, roomMaterial );\n\t\troom.position.set( - 0.757, 13.219, 0.717 );\n\t\troom.scale.set( 31.713, 28.305, 28.591 );\n\t\tthis.add( room );\n\n\t\tconst boxes = new InstancedMesh( geometry, boxMaterial, 6 );\n\t\tconst transform = new Object3D();\n\n\t\t// box1\n\t\ttransform.position.set( - 10.906, 2.009, 1.846 );\n\t\ttransform.rotation.set( 0, - 0.195, 0 );\n\t\ttransform.scale.set( 2.328, 7.905, 4.651 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 0, transform.matrix );\n\n\t\t// box2\n\t\ttransform.position.set( - 5.607, - 0.754, - 0.758 );\n\t\ttransform.rotation.set( 0, 0.994, 0 );\n\t\ttransform.scale.set( 1.970, 1.534, 3.955 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 1, transform.matrix );\n\n\t\t// box3\n\t\ttransform.position.set( 6.167, 0.857, 7.803 );\n\t\ttransform.rotation.set( 0, 0.561, 0 );\n\t\ttransform.scale.set( 3.927, 6.285, 3.687 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 2, transform.matrix );\n\n\t\t// box4\n\t\ttransform.position.set( - 2.017, 0.018, 6.124 );\n\t\ttransform.rotation.set( 0, 0.333, 0 );\n\t\ttransform.scale.set( 2.002, 4.566, 2.064 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 3, transform.matrix );\n\n\t\t// box5\n\t\ttransform.position.set( 2.291, - 0.756, - 2.621 );\n\t\ttransform.rotation.set( 0, - 0.286, 0 );\n\t\ttransform.scale.set( 1.546, 1.552, 1.496 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 4, transform.matrix );\n\n\t\t// box6\n\t\ttransform.position.set( - 2.193, - 0.369, - 5.547 );\n\t\ttransform.rotation.set( 0, 0.516, 0 );\n\t\ttransform.scale.set( 3.875, 3.487, 2.986 );\n\t\ttransform.updateMatrix();\n\t\tboxes.setMatrixAt( 5, transform.matrix );\n\n\t\tthis.add( boxes );\n\n\n\t\t// -x right\n\t\tconst light1 = new Mesh( geometry, createAreaLightMaterial( 50 ) );\n\t\tlight1.position.set( - 16.116, 14.37, 8.208 );\n\t\tlight1.scale.set( 0.1, 2.428, 2.739 );\n\t\tthis.add( light1 );\n\n\t\t// -x left\n\t\tconst light2 = new Mesh( geometry, createAreaLightMaterial( 50 ) );\n\t\tlight2.position.set( - 16.109, 18.021, - 8.207 );\n\t\tlight2.scale.set( 0.1, 2.425, 2.751 );\n\t\tthis.add( light2 );\n\n\t\t// +x\n\t\tconst light3 = new Mesh( geometry, createAreaLightMaterial( 17 ) );\n\t\tlight3.position.set( 14.904, 12.198, - 1.832 );\n\t\tlight3.scale.set( 0.15, 4.265, 6.331 );\n\t\tthis.add( light3 );\n\n\t\t// +z\n\t\tconst light4 = new Mesh( geometry, createAreaLightMaterial( 43 ) );\n\t\tlight4.position.set( - 0.462, 8.89, 14.520 );\n\t\tlight4.scale.set( 4.38, 5.441, 0.088 );\n\t\tthis.add( light4 );\n\n\t\t// -z\n\t\tconst light5 = new Mesh( geometry, createAreaLightMaterial( 20 ) );\n\t\tlight5.position.set( 3.235, 11.486, - 12.541 );\n\t\tlight5.scale.set( 2.5, 2.0, 0.1 );\n\t\tthis.add( light5 );\n\n\t\t// +y\n\t\tconst light6 = new Mesh( geometry, createAreaLightMaterial( 100 ) );\n\t\tlight6.position.set( 0.0, 20.0, 0.0 );\n\t\tlight6.scale.set( 1.0, 0.1, 1.0 );\n\t\tthis.add( light6 );\n\n\t}\n\n\t/**\n\t * Frees internal resources. This method should be called\n\t * when the environment is no longer required.\n\t */\n\tdispose() {\n\n\t\tconst resources = new Set();\n\n\t\tthis.traverse( ( object ) => {\n\n\t\t\tif ( object.isMesh ) {\n\n\t\t\t\tresources.add( object.geometry );\n\t\t\t\tresources.add( object.material );\n\n\t\t\t}\n\n\t\t} );\n\n\t\tfor ( const resource of resources ) {\n\n\t\t\tresource.dispose();\n\n\t\t}\n\n\t}\n\n}\n\nfunction createAreaLightMaterial( intensity ) {\n\n\t// create an emissive-only material. see #31348\n\tconst material = new MeshLambertMaterial( {\n\t\tcolor: 0x000000,\n\t\temissive: 0xffffff,\n\t\temissiveIntensity: intensity\n\t} );\n\n\treturn material;\n\n}\n\nexport { RoomEnvironment };\n","///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2026, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { PMREMGenerator } from \"three\";\nimport { RoomEnvironment } from \"three/examples/jsm/environments/RoomEnvironment.js\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass RoomEnvironmentComponent implements IComponent {\n protected viewer: Viewer;\n\n constructor(viewer: Viewer) {\n this.viewer = viewer;\n\n const environment = new RoomEnvironment();\n const pmremGenerator = new PMREMGenerator(this.viewer.renderer);\n\n this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;\n\n environment.dispose();\n }\n\n dispose() {\n this.viewer.scene.environment = undefined;\n }\n}\n\ncomponents.registerComponent(\"LightComponent\", (viewer) => new RoomEnvironmentComponent(viewer));\n"],"names":["Scene","BoxGeometry","MeshStandardMaterial","BackSide","PointLight","Mesh","InstancedMesh","Object3D","MeshLambertMaterial","PMREMGenerator","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCA,MAAM,eAAe,SAASA,WAAK,CAAC;CAEpC,CAAC,WAAW,GAAG;CAEf,EAAE,KAAK,EAAE;CAET,EAAE,IAAI,CAAC,IAAI,GAAG,iBAAiB;CAC/B,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAK;CAEzB,EAAE,MAAM,QAAQ,GAAG,IAAIC,iBAAW,EAAE;CACpC,EAAE,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE;CAElC,EAAE,MAAM,YAAY,GAAG,IAAIC,0BAAoB,EAAE,EAAE,IAAI,EAAEC,cAAQ,EAAE,EAAE;CACrE,EAAE,MAAM,WAAW,GAAG,IAAID,0BAAoB,EAAE;CAEhD,EAAE,MAAM,SAAS,G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///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,t){"use strict";class s extends e.Scene{constructor(){super(),this.name="RoomEnvironment";const t=new e.BoxGeometry;t.deleteAttribute("uv");const s=new e.MeshStandardMaterial({side:e.BackSide}),n=new e.MeshStandardMaterial,o=new e.PointLight(16777215,900,28,2);o.position.set(.418,16.199,.3),this.add(o);const a=new e.Mesh(t,s);a.position.set(-.757,13.219,.717),a.scale.set(31.713,28.305,28.591),this.add(a);const r=new e.InstancedMesh(t,n,6),d=new e.Object3D;d.position.set(-10.906,2.009,1.846),d.rotation.set(0,-.195,0),d.scale.set(2.328,7.905,4.651),d.updateMatrix(),r.setMatrixAt(0,d.matrix),d.position.set(-5.607,-.754,-.758),d.rotation.set(0,.994,0),d.scale.set(1.97,1.534,3.955),d.updateMatrix(),r.setMatrixAt(1,d.matrix),d.position.set(6.167,.857,7.803),d.rotation.set(0,.561,0),d.scale.set(3.927,6.285,3.687),d.updateMatrix(),r.setMatrixAt(2,d.matrix),d.position.set(-2.017,.018,6.124),d.rotation.set(0,.333,0),d.scale.set(2.002,4.566,2.064),d.updateMatrix(),r.setMatrixAt(3,d.matrix),d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),d.updateMatrix(),r.setMatrixAt(4,d.matrix),d.position.set(-2.193,-.369,-5.547),d.rotation.set(0,.516,0),d.scale.set(3.875,3.487,2.986),d.updateMatrix(),r.setMatrixAt(5,d.matrix),this.add(r);const c=new e.Mesh(t,i(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);const h=new e.Mesh(t,i(50));h.position.set(-16.109,18.021,-8.207),h.scale.set(.1,2.425,2.751),this.add(h);const p=new e.Mesh(t,i(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const M=new e.Mesh(t,i(43));M.position.set(-.462,8.89,14.52),M.scale.set(4.38,5.441,.088),this.add(M);const l=new e.Mesh(t,i(20));l.position.set(3.235,11.486,-12.541),l.scale.set(2.5,2,.1),this.add(l);const w=new e.Mesh(t,i(100));w.position.set(0,20,0),w.scale.set(1,.1,1),this.add(w)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function i(t){return new e.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:t})}class n{constructor(t){this.viewer=t;const i=new s,n=new e.PMREMGenerator(this.viewer.renderer);this.viewer.scene.environment=n.fromScene(i).texture,i.dispose()}dispose(){this.viewer.scene.environment=void 0}}t.components.registerComponent("LightComponent",e=>new n(e))});
|
|
24
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,t){"use strict";class s extends e.Scene{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;const t=new e.BoxGeometry;t.deleteAttribute("uv");const s=new e.MeshStandardMaterial({side:e.BackSide}),n=new e.MeshStandardMaterial,o=new e.PointLight(16777215,900,28,2);o.position.set(.418,16.199,.3),this.add(o);const a=new e.Mesh(t,s);a.position.set(-.757,13.219,.717),a.scale.set(31.713,28.305,28.591),this.add(a);const r=new e.InstancedMesh(t,n,6),d=new e.Object3D;d.position.set(-10.906,2.009,1.846),d.rotation.set(0,-.195,0),d.scale.set(2.328,7.905,4.651),d.updateMatrix(),r.setMatrixAt(0,d.matrix),d.position.set(-5.607,-.754,-.758),d.rotation.set(0,.994,0),d.scale.set(1.97,1.534,3.955),d.updateMatrix(),r.setMatrixAt(1,d.matrix),d.position.set(6.167,.857,7.803),d.rotation.set(0,.561,0),d.scale.set(3.927,6.285,3.687),d.updateMatrix(),r.setMatrixAt(2,d.matrix),d.position.set(-2.017,.018,6.124),d.rotation.set(0,.333,0),d.scale.set(2.002,4.566,2.064),d.updateMatrix(),r.setMatrixAt(3,d.matrix),d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),d.updateMatrix(),r.setMatrixAt(4,d.matrix),d.position.set(-2.193,-.369,-5.547),d.rotation.set(0,.516,0),d.scale.set(3.875,3.487,2.986),d.updateMatrix(),r.setMatrixAt(5,d.matrix),this.add(r);const c=new e.Mesh(t,i(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);const h=new e.Mesh(t,i(50));h.position.set(-16.109,18.021,-8.207),h.scale.set(.1,2.425,2.751),this.add(h);const p=new e.Mesh(t,i(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),this.add(p);const M=new e.Mesh(t,i(43));M.position.set(-.462,8.89,14.52),M.scale.set(4.38,5.441,.088),this.add(M);const l=new e.Mesh(t,i(20));l.position.set(3.235,11.486,-12.541),l.scale.set(2.5,2,.1),this.add(l);const w=new e.Mesh(t,i(100));w.position.set(0,20,0),w.scale.set(1,.1,1),this.add(w)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function i(t){return new e.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:t})}class n{constructor(t){this.viewer=t;const i=new s,n=new e.PMREMGenerator(this.viewer.renderer);this.viewer.scene.environment=n.fromScene(i).texture,i.dispose()}dispose(){this.viewer.scene.environment=void 0}}t.components.registerComponent("LightComponent",e=>new n(e))});
|
|
@@ -82,6 +82,35 @@
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function clone( source ) {
|
|
86
|
+
const sourceLookup = new Map();
|
|
87
|
+
const cloneLookup = new Map();
|
|
88
|
+
const clone = source.clone();
|
|
89
|
+
parallelTraverse( source, clone, function ( sourceNode, clonedNode ) {
|
|
90
|
+
sourceLookup.set( clonedNode, sourceNode );
|
|
91
|
+
cloneLookup.set( sourceNode, clonedNode );
|
|
92
|
+
} );
|
|
93
|
+
clone.traverse( function ( node ) {
|
|
94
|
+
if ( ! node.isSkinnedMesh ) return;
|
|
95
|
+
const clonedMesh = node;
|
|
96
|
+
const sourceMesh = sourceLookup.get( node );
|
|
97
|
+
const sourceBones = sourceMesh.skeleton.bones;
|
|
98
|
+
clonedMesh.skeleton = sourceMesh.skeleton.clone();
|
|
99
|
+
clonedMesh.bindMatrix.copy( sourceMesh.bindMatrix );
|
|
100
|
+
clonedMesh.skeleton.bones = sourceBones.map( function ( bone ) {
|
|
101
|
+
return cloneLookup.get( bone );
|
|
102
|
+
} );
|
|
103
|
+
clonedMesh.bind( clonedMesh.skeleton, clonedMesh.bindMatrix );
|
|
104
|
+
} );
|
|
105
|
+
return clone;
|
|
106
|
+
}
|
|
107
|
+
function parallelTraverse( a, b, callback ) {
|
|
108
|
+
callback( a, b );
|
|
109
|
+
for ( let i = 0; i < a.children.length; i ++ ) {
|
|
110
|
+
parallelTraverse( a.children[ i ], b.children[ i ], callback );
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
85
114
|
class GLTFLoader extends three.Loader {
|
|
86
115
|
constructor( manager ) {
|
|
87
116
|
super( manager );
|
|
@@ -135,7 +164,10 @@
|
|
|
135
164
|
return new GLTFLightsExtension( parser );
|
|
136
165
|
} );
|
|
137
166
|
this.register( function ( parser ) {
|
|
138
|
-
return new GLTFMeshoptCompression( parser );
|
|
167
|
+
return new GLTFMeshoptCompression( parser, EXTENSIONS.EXT_MESHOPT_COMPRESSION );
|
|
168
|
+
} );
|
|
169
|
+
this.register( function ( parser ) {
|
|
170
|
+
return new GLTFMeshoptCompression( parser, EXTENSIONS.KHR_MESHOPT_COMPRESSION );
|
|
139
171
|
} );
|
|
140
172
|
this.register( function ( parser ) {
|
|
141
173
|
return new GLTFMeshGpuInstancing( parser );
|
|
@@ -296,6 +328,13 @@
|
|
|
296
328
|
}
|
|
297
329
|
};
|
|
298
330
|
}
|
|
331
|
+
function getMaterialExtension( parser, materialIndex, extensionName ) {
|
|
332
|
+
const materialDef = parser.json.materials[ materialIndex ];
|
|
333
|
+
if ( materialDef.extensions && materialDef.extensions[ extensionName ] ) {
|
|
334
|
+
return materialDef.extensions[ extensionName ];
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
299
338
|
const EXTENSIONS = {
|
|
300
339
|
KHR_BINARY_GLTF: 'KHR_binary_glTF',
|
|
301
340
|
KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
|
|
@@ -318,6 +357,7 @@
|
|
|
318
357
|
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
319
358
|
EXT_TEXTURE_AVIF: 'EXT_texture_avif',
|
|
320
359
|
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
360
|
+
KHR_MESHOPT_COMPRESSION: 'KHR_meshopt_compression',
|
|
321
361
|
EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
|
|
322
362
|
};
|
|
323
363
|
class GLTFLightsExtension {
|
|
@@ -431,14 +471,10 @@
|
|
|
431
471
|
this.name = EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
432
472
|
}
|
|
433
473
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
|
|
440
|
-
if ( emissiveStrength !== undefined ) {
|
|
441
|
-
materialParams.emissiveIntensity = emissiveStrength;
|
|
474
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
475
|
+
if ( extension === null ) return Promise.resolve();
|
|
476
|
+
if ( extension.emissiveStrength !== undefined ) {
|
|
477
|
+
materialParams.emissiveIntensity = extension.emissiveStrength;
|
|
442
478
|
}
|
|
443
479
|
return Promise.resolve();
|
|
444
480
|
}
|
|
@@ -449,33 +485,27 @@
|
|
|
449
485
|
this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
|
|
450
486
|
}
|
|
451
487
|
getMaterialType( materialIndex ) {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
455
|
-
return three.MeshPhysicalMaterial;
|
|
488
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
489
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
456
490
|
}
|
|
457
491
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
461
|
-
return Promise.resolve();
|
|
462
|
-
}
|
|
492
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
493
|
+
if ( extension === null ) return Promise.resolve();
|
|
463
494
|
const pending = [];
|
|
464
|
-
const extension = materialDef.extensions[ this.name ];
|
|
465
495
|
if ( extension.clearcoatFactor !== undefined ) {
|
|
466
496
|
materialParams.clearcoat = extension.clearcoatFactor;
|
|
467
497
|
}
|
|
468
498
|
if ( extension.clearcoatTexture !== undefined ) {
|
|
469
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
499
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
|
|
470
500
|
}
|
|
471
501
|
if ( extension.clearcoatRoughnessFactor !== undefined ) {
|
|
472
502
|
materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
|
|
473
503
|
}
|
|
474
504
|
if ( extension.clearcoatRoughnessTexture !== undefined ) {
|
|
475
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
505
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
|
|
476
506
|
}
|
|
477
507
|
if ( extension.clearcoatNormalTexture !== undefined ) {
|
|
478
|
-
pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
508
|
+
pending.push( this.parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
|
|
479
509
|
if ( extension.clearcoatNormalTexture.scale !== undefined ) {
|
|
480
510
|
const scale = extension.clearcoatNormalTexture.scale;
|
|
481
511
|
materialParams.clearcoatNormalScale = new three.Vector2( scale, scale );
|
|
@@ -490,18 +520,12 @@
|
|
|
490
520
|
this.name = EXTENSIONS.KHR_MATERIALS_DISPERSION;
|
|
491
521
|
}
|
|
492
522
|
getMaterialType( materialIndex ) {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
496
|
-
return three.MeshPhysicalMaterial;
|
|
523
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
524
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
497
525
|
}
|
|
498
526
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
502
|
-
return Promise.resolve();
|
|
503
|
-
}
|
|
504
|
-
const extension = materialDef.extensions[ this.name ];
|
|
527
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
528
|
+
if ( extension === null ) return Promise.resolve();
|
|
505
529
|
materialParams.dispersion = extension.dispersion !== undefined ? extension.dispersion : 0;
|
|
506
530
|
return Promise.resolve();
|
|
507
531
|
}
|
|
@@ -512,24 +536,18 @@
|
|
|
512
536
|
this.name = EXTENSIONS.KHR_MATERIALS_IRIDESCENCE;
|
|
513
537
|
}
|
|
514
538
|
getMaterialType( materialIndex ) {
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
518
|
-
return three.MeshPhysicalMaterial;
|
|
539
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
540
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
519
541
|
}
|
|
520
542
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
524
|
-
return Promise.resolve();
|
|
525
|
-
}
|
|
543
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
544
|
+
if ( extension === null ) return Promise.resolve();
|
|
526
545
|
const pending = [];
|
|
527
|
-
const extension = materialDef.extensions[ this.name ];
|
|
528
546
|
if ( extension.iridescenceFactor !== undefined ) {
|
|
529
547
|
materialParams.iridescence = extension.iridescenceFactor;
|
|
530
548
|
}
|
|
531
549
|
if ( extension.iridescenceTexture !== undefined ) {
|
|
532
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
550
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
|
|
533
551
|
}
|
|
534
552
|
if ( extension.iridescenceIor !== undefined ) {
|
|
535
553
|
materialParams.iridescenceIOR = extension.iridescenceIor;
|
|
@@ -544,7 +562,7 @@
|
|
|
544
562
|
materialParams.iridescenceThicknessRange[ 1 ] = extension.iridescenceThicknessMaximum;
|
|
545
563
|
}
|
|
546
564
|
if ( extension.iridescenceThicknessTexture !== undefined ) {
|
|
547
|
-
pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
565
|
+
pending.push( this.parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
|
|
548
566
|
}
|
|
549
567
|
return Promise.all( pending );
|
|
550
568
|
}
|
|
@@ -555,22 +573,16 @@
|
|
|
555
573
|
this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
|
|
556
574
|
}
|
|
557
575
|
getMaterialType( materialIndex ) {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
561
|
-
return three.MeshPhysicalMaterial;
|
|
576
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
577
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
562
578
|
}
|
|
563
579
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
567
|
-
return Promise.resolve();
|
|
568
|
-
}
|
|
580
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
581
|
+
if ( extension === null ) return Promise.resolve();
|
|
569
582
|
const pending = [];
|
|
570
583
|
materialParams.sheenColor = new three.Color( 0, 0, 0 );
|
|
571
584
|
materialParams.sheenRoughness = 0;
|
|
572
585
|
materialParams.sheen = 1;
|
|
573
|
-
const extension = materialDef.extensions[ this.name ];
|
|
574
586
|
if ( extension.sheenColorFactor !== undefined ) {
|
|
575
587
|
const colorFactor = extension.sheenColorFactor;
|
|
576
588
|
materialParams.sheenColor.setRGB( colorFactor[ 0 ], colorFactor[ 1 ], colorFactor[ 2 ], three.LinearSRGBColorSpace );
|
|
@@ -579,10 +591,10 @@
|
|
|
579
591
|
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
|
580
592
|
}
|
|
581
593
|
if ( extension.sheenColorTexture !== undefined ) {
|
|
582
|
-
pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, three.SRGBColorSpace ) );
|
|
594
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, three.SRGBColorSpace ) );
|
|
583
595
|
}
|
|
584
596
|
if ( extension.sheenRoughnessTexture !== undefined ) {
|
|
585
|
-
pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
597
|
+
pending.push( this.parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
|
|
586
598
|
}
|
|
587
599
|
return Promise.all( pending );
|
|
588
600
|
}
|
|
@@ -593,24 +605,18 @@
|
|
|
593
605
|
this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
|
|
594
606
|
}
|
|
595
607
|
getMaterialType( materialIndex ) {
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
599
|
-
return three.MeshPhysicalMaterial;
|
|
608
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
609
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
600
610
|
}
|
|
601
611
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
605
|
-
return Promise.resolve();
|
|
606
|
-
}
|
|
612
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
613
|
+
if ( extension === null ) return Promise.resolve();
|
|
607
614
|
const pending = [];
|
|
608
|
-
const extension = materialDef.extensions[ this.name ];
|
|
609
615
|
if ( extension.transmissionFactor !== undefined ) {
|
|
610
616
|
materialParams.transmission = extension.transmissionFactor;
|
|
611
617
|
}
|
|
612
618
|
if ( extension.transmissionTexture !== undefined ) {
|
|
613
|
-
pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
619
|
+
pending.push( this.parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
|
|
614
620
|
}
|
|
615
621
|
return Promise.all( pending );
|
|
616
622
|
}
|
|
@@ -621,22 +627,16 @@
|
|
|
621
627
|
this.name = EXTENSIONS.KHR_MATERIALS_VOLUME;
|
|
622
628
|
}
|
|
623
629
|
getMaterialType( materialIndex ) {
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
627
|
-
return three.MeshPhysicalMaterial;
|
|
630
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
631
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
628
632
|
}
|
|
629
633
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
633
|
-
return Promise.resolve();
|
|
634
|
-
}
|
|
634
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
635
|
+
if ( extension === null ) return Promise.resolve();
|
|
635
636
|
const pending = [];
|
|
636
|
-
const extension = materialDef.extensions[ this.name ];
|
|
637
637
|
materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
|
|
638
638
|
if ( extension.thicknessTexture !== undefined ) {
|
|
639
|
-
pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
639
|
+
pending.push( this.parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
|
|
640
640
|
}
|
|
641
641
|
materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
|
|
642
642
|
const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
|
|
@@ -650,19 +650,14 @@
|
|
|
650
650
|
this.name = EXTENSIONS.KHR_MATERIALS_IOR;
|
|
651
651
|
}
|
|
652
652
|
getMaterialType( materialIndex ) {
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
656
|
-
return three.MeshPhysicalMaterial;
|
|
653
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
654
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
657
655
|
}
|
|
658
656
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
662
|
-
return Promise.resolve();
|
|
663
|
-
}
|
|
664
|
-
const extension = materialDef.extensions[ this.name ];
|
|
657
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
658
|
+
if ( extension === null ) return Promise.resolve();
|
|
665
659
|
materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
|
|
660
|
+
if ( materialParams.ior === 0 ) materialParams.ior = 1000;
|
|
666
661
|
return Promise.resolve();
|
|
667
662
|
}
|
|
668
663
|
}
|
|
@@ -672,27 +667,21 @@
|
|
|
672
667
|
this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;
|
|
673
668
|
}
|
|
674
669
|
getMaterialType( materialIndex ) {
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
678
|
-
return three.MeshPhysicalMaterial;
|
|
670
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
671
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
679
672
|
}
|
|
680
673
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
684
|
-
return Promise.resolve();
|
|
685
|
-
}
|
|
674
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
675
|
+
if ( extension === null ) return Promise.resolve();
|
|
686
676
|
const pending = [];
|
|
687
|
-
const extension = materialDef.extensions[ this.name ];
|
|
688
677
|
materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
|
|
689
678
|
if ( extension.specularTexture !== undefined ) {
|
|
690
|
-
pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
679
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
|
|
691
680
|
}
|
|
692
681
|
const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
|
|
693
682
|
materialParams.specularColor = new three.Color().setRGB( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ], three.LinearSRGBColorSpace );
|
|
694
683
|
if ( extension.specularColorTexture !== undefined ) {
|
|
695
|
-
pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, three.SRGBColorSpace ) );
|
|
684
|
+
pending.push( this.parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, three.SRGBColorSpace ) );
|
|
696
685
|
}
|
|
697
686
|
return Promise.all( pending );
|
|
698
687
|
}
|
|
@@ -703,22 +692,16 @@
|
|
|
703
692
|
this.name = EXTENSIONS.EXT_MATERIALS_BUMP;
|
|
704
693
|
}
|
|
705
694
|
getMaterialType( materialIndex ) {
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
709
|
-
return three.MeshPhysicalMaterial;
|
|
695
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
696
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
710
697
|
}
|
|
711
698
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
715
|
-
return Promise.resolve();
|
|
716
|
-
}
|
|
699
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
700
|
+
if ( extension === null ) return Promise.resolve();
|
|
717
701
|
const pending = [];
|
|
718
|
-
const extension = materialDef.extensions[ this.name ];
|
|
719
702
|
materialParams.bumpScale = extension.bumpFactor !== undefined ? extension.bumpFactor : 1.0;
|
|
720
703
|
if ( extension.bumpTexture !== undefined ) {
|
|
721
|
-
pending.push( parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
704
|
+
pending.push( this.parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
|
|
722
705
|
}
|
|
723
706
|
return Promise.all( pending );
|
|
724
707
|
}
|
|
@@ -729,19 +712,13 @@
|
|
|
729
712
|
this.name = EXTENSIONS.KHR_MATERIALS_ANISOTROPY;
|
|
730
713
|
}
|
|
731
714
|
getMaterialType( materialIndex ) {
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
735
|
-
return three.MeshPhysicalMaterial;
|
|
715
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
716
|
+
return extension !== null ? three.MeshPhysicalMaterial : null;
|
|
736
717
|
}
|
|
737
718
|
extendMaterialParams( materialIndex, materialParams ) {
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
741
|
-
return Promise.resolve();
|
|
742
|
-
}
|
|
719
|
+
const extension = getMaterialExtension( this.parser, materialIndex, this.name );
|
|
720
|
+
if ( extension === null ) return Promise.resolve();
|
|
743
721
|
const pending = [];
|
|
744
|
-
const extension = materialDef.extensions[ this.name ];
|
|
745
722
|
if ( extension.anisotropyStrength !== undefined ) {
|
|
746
723
|
materialParams.anisotropy = extension.anisotropyStrength;
|
|
747
724
|
}
|
|
@@ -749,7 +726,7 @@
|
|
|
749
726
|
materialParams.anisotropyRotation = extension.anisotropyRotation;
|
|
750
727
|
}
|
|
751
728
|
if ( extension.anisotropyTexture !== undefined ) {
|
|
752
|
-
pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
729
|
+
pending.push( this.parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
753
730
|
}
|
|
754
731
|
return Promise.all( pending );
|
|
755
732
|
}
|
|
@@ -825,8 +802,8 @@
|
|
|
825
802
|
}
|
|
826
803
|
}
|
|
827
804
|
class GLTFMeshoptCompression {
|
|
828
|
-
constructor( parser ) {
|
|
829
|
-
this.name =
|
|
805
|
+
constructor( parser, name ) {
|
|
806
|
+
this.name = name;
|
|
830
807
|
this.parser = parser;
|
|
831
808
|
}
|
|
832
809
|
loadBufferView( index ) {
|
|
@@ -1348,7 +1325,7 @@
|
|
|
1348
1325
|
let safariVersion = -1;
|
|
1349
1326
|
let isFirefox = false;
|
|
1350
1327
|
let firefoxVersion = -1;
|
|
1351
|
-
if ( typeof navigator !== 'undefined' ) {
|
|
1328
|
+
if ( typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined' ) {
|
|
1352
1329
|
const userAgent = navigator.userAgent;
|
|
1353
1330
|
isSafari = /^((?!chrome|android).)*safari/i.test( userAgent ) === true;
|
|
1354
1331
|
const safariMatch = userAgent.match( /Version\/(\d+)/ );
|
|
@@ -2172,6 +2149,16 @@
|
|
|
2172
2149
|
for ( let i = 0, il = children.length; i < il; i ++ ) {
|
|
2173
2150
|
node.add( children[ i ] );
|
|
2174
2151
|
}
|
|
2152
|
+
if ( node.userData.pivot !== undefined && children.length > 0 ) {
|
|
2153
|
+
const pivot = node.userData.pivot;
|
|
2154
|
+
const pivotChild = children[ 0 ];
|
|
2155
|
+
node.pivot = new three.Vector3().fromArray( pivot );
|
|
2156
|
+
node.position.x -= pivot[ 0 ];
|
|
2157
|
+
node.position.y -= pivot[ 1 ];
|
|
2158
|
+
node.position.z -= pivot[ 2 ];
|
|
2159
|
+
pivotChild.position.set( 0, 0, 0 );
|
|
2160
|
+
delete node.userData.pivot;
|
|
2161
|
+
}
|
|
2175
2162
|
return node;
|
|
2176
2163
|
} );
|
|
2177
2164
|
}
|
|
@@ -2264,7 +2251,12 @@
|
|
|
2264
2251
|
}
|
|
2265
2252
|
return Promise.all( pending ).then( function ( nodes ) {
|
|
2266
2253
|
for ( let i = 0, il = nodes.length; i < il; i ++ ) {
|
|
2267
|
-
|
|
2254
|
+
const node = nodes[ i ];
|
|
2255
|
+
if ( node.parent !== null ) {
|
|
2256
|
+
scene.add( clone( node ) );
|
|
2257
|
+
} else {
|
|
2258
|
+
scene.add( node );
|
|
2259
|
+
}
|
|
2268
2260
|
}
|
|
2269
2261
|
const reduceAssociations = ( node ) => {
|
|
2270
2262
|
const reducedAssociations = new Map();
|
|
@@ -2289,12 +2281,16 @@
|
|
|
2289
2281
|
const tracks = [];
|
|
2290
2282
|
const targetName = node.name ? node.name : node.uuid;
|
|
2291
2283
|
const targetNames = [];
|
|
2284
|
+
function collectMorphTargets( object ) {
|
|
2285
|
+
if ( object.morphTargetInfluences ) {
|
|
2286
|
+
targetNames.push( object.name ? object.name : object.uuid );
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2292
2289
|
if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
} );
|
|
2290
|
+
collectMorphTargets( node );
|
|
2291
|
+
if ( node.isGroup ) {
|
|
2292
|
+
node.children.forEach( collectMorphTargets );
|
|
2293
|
+
}
|
|
2298
2294
|
} else {
|
|
2299
2295
|
targetNames.push( targetName );
|
|
2300
2296
|
}
|