@aibee/owlly 1.0.26 → 1.0.29
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/lib/external/lines/line-geometry.d.ts +9 -0
- package/lib/external/lines/line-geometry.js +51 -0
- package/lib/external/lines/line-material.d.ts +10 -0
- package/lib/external/lines/line-material.js +376 -0
- package/lib/external/lines/line-segments-2.d.ts +7 -0
- package/lib/external/lines/line-segments-2.js +143 -0
- package/lib/external/lines/line-segments-geometry.d.ts +15 -0
- package/lib/external/lines/line-segments-geometry.js +140 -0
- package/lib/external/loaders/gltf-loader.d.ts +77 -0
- package/lib/external/loaders/gltf-loader.js +2318 -0
- package/lib/external/orbit-controls.d.ts +44 -0
- package/lib/external/orbit-controls.js +745 -0
- package/lib/external/renderers/css-2d-renderer.d.ts +16 -0
- package/lib/external/renderers/css-2d-renderer.js +121 -0
- package/lib/external/renderers/css-3d-renderer.d.ts +18 -0
- package/lib/external/renderers/css-3d-renderer.js +138 -0
- package/lib/external/transform-controls.d.ts +106 -0
- package/lib/external/transform-controls.js +1112 -0
- package/lib/owlly/controller/aerial-element-controller.d.ts +65 -0
- package/lib/owlly/controller/aerial-element-controller.js +235 -0
- package/lib/owlly/controller/basic-controller.d.ts +324 -0
- package/lib/owlly/controller/basic-controller.js +1238 -0
- package/lib/owlly/controller/camera-controller.d.ts +37 -0
- package/lib/owlly/controller/camera-controller.js +137 -0
- package/lib/owlly/controller/controller.d.ts +61 -0
- package/lib/owlly/controller/controller.js +23 -0
- package/lib/owlly/controller/index.d.ts +2 -0
- package/lib/owlly/controller/index.js +13 -0
- package/lib/owlly/controller/mouse-indicator-controller.d.ts +34 -0
- package/lib/owlly/controller/mouse-indicator-controller.js +118 -0
- package/lib/owlly/controller/orbit-control.d.ts +147 -0
- package/lib/owlly/controller/orbit-control.js +264 -0
- package/lib/owlly/controller/panorama-adjust-controller.d.ts +45 -0
- package/lib/owlly/controller/panorama-adjust-controller.js +157 -0
- package/lib/owlly/controller/panorama-controller.d.ts +441 -0
- package/lib/owlly/controller/panorama-controller.js +1943 -0
- package/lib/owlly/controller/panorama-transform-controller.d.ts +66 -0
- package/lib/owlly/controller/panorama-transform-controller.js +136 -0
- package/lib/owlly/controller/plane-controller.d.ts +43 -0
- package/lib/owlly/controller/plane-controller.js +173 -0
- package/lib/owlly/controller/texture-controller.d.ts +181 -0
- package/lib/owlly/controller/texture-controller.js +875 -0
- package/lib/owlly/controller/tile-panorama-controller.d.ts +308 -0
- package/lib/owlly/controller/tile-panorama-controller.js +1353 -0
- package/lib/owlly/controller/transform-controller.d.ts +106 -0
- package/lib/owlly/controller/transform-controller.js +545 -0
- package/lib/owlly/element/bottom-nav-element.d.ts +65 -0
- package/lib/owlly/element/bottom-nav-element.js +257 -0
- package/lib/owlly/element/camera.d.ts +82 -0
- package/lib/owlly/element/camera.js +283 -0
- package/lib/owlly/element/dom-2d-element.d.ts +35 -0
- package/lib/owlly/element/dom-2d-element.js +48 -0
- package/lib/owlly/element/dom-3d-element.d.ts +27 -0
- package/lib/owlly/element/dom-3d-element.js +33 -0
- package/lib/owlly/element/dom-label-2d.d.ts +116 -0
- package/lib/owlly/element/dom-label-2d.js +382 -0
- package/lib/owlly/element/element.d.ts +53 -0
- package/lib/owlly/element/element.js +75 -0
- package/lib/owlly/element/floor-model.d.ts +83 -0
- package/lib/owlly/element/floor-model.js +227 -0
- package/lib/owlly/element/gif-kit/Gif.d.ts +96 -0
- package/lib/owlly/element/gif-kit/Gif.js +432 -0
- package/lib/owlly/element/gif-kit/GifColor.d.ts +21 -0
- package/lib/owlly/element/gif-kit/GifColor.js +37 -0
- package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
- package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +50 -0
- package/lib/owlly/element/gif-kit/GifFrame.d.ts +31 -0
- package/lib/owlly/element/gif-kit/GifFrame.js +96 -0
- package/lib/owlly/element/gif-kit/GifImage.d.ts +23 -0
- package/lib/owlly/element/gif-kit/GifImage.js +7 -0
- package/lib/owlly/element/gif-kit/GifParser.d.ts +17 -0
- package/lib/owlly/element/gif-kit/GifParser.js +196 -0
- package/lib/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
- package/lib/owlly/element/gif-kit/GifPresenter.js +43 -0
- package/lib/owlly/element/gif-kit/GifVersion.d.ts +10 -0
- package/lib/owlly/element/gif-kit/GifVersion.js +12 -0
- package/lib/owlly/element/gltf-mesh-element.d.ts +31 -0
- package/lib/owlly/element/gltf-mesh-element.js +136 -0
- package/lib/owlly/element/index.d.ts +20 -0
- package/lib/owlly/element/index.js +24 -0
- package/lib/owlly/element/map-kit/shape.d.ts +131 -0
- package/lib/owlly/element/map-kit/shape.js +189 -0
- package/lib/owlly/element/mesh-element.d.ts +22 -0
- package/lib/owlly/element/mesh-element.js +63 -0
- package/lib/owlly/element/mesh-line-2d.d.ts +82 -0
- package/lib/owlly/element/mesh-line-2d.js +887 -0
- package/lib/owlly/element/meshline-o.d.ts +64 -0
- package/lib/owlly/element/meshline-o.js +678 -0
- package/lib/owlly/element/panorama-group.d.ts +241 -0
- package/lib/owlly/element/panorama-group.js +966 -0
- package/lib/owlly/element/panorama.d.ts +132 -0
- package/lib/owlly/element/panorama.js +812 -0
- package/lib/owlly/element/path-group.d.ts +69 -0
- package/lib/owlly/element/path-group.js +171 -0
- package/lib/owlly/element/path.d.ts +99 -0
- package/lib/owlly/element/path.js +531 -0
- package/lib/owlly/element/placeable-2d.d.ts +158 -0
- package/lib/owlly/element/placeable-2d.js +470 -0
- package/lib/owlly/element/polygon-mesh.d.ts +107 -0
- package/lib/owlly/element/polygon-mesh.js +307 -0
- package/lib/owlly/element/ring-element.d.ts +79 -0
- package/lib/owlly/element/ring-element.js +383 -0
- package/lib/owlly/element/sphere-mesh.d.ts +28 -0
- package/lib/owlly/element/sphere-mesh.js +69 -0
- package/lib/owlly/element/svg-floor-model.d.ts +22 -0
- package/lib/owlly/element/svg-floor-model.js +184 -0
- package/lib/owlly/element/svg-floors.d.ts +27 -0
- package/lib/owlly/element/svg-floors.js +109 -0
- package/lib/owlly/element/tile-panorama-group.d.ts +335 -0
- package/lib/owlly/element/tile-panorama-group.js +1006 -0
- package/lib/owlly/element/tile-panorama.d.ts +161 -0
- package/lib/owlly/element/tile-panorama.js +509 -0
- package/lib/owlly/element/tile-plane.d.ts +105 -0
- package/lib/owlly/element/tile-plane.js +360 -0
- package/lib/owlly/element/video-element.d.ts +33 -0
- package/lib/owlly/element/video-element.js +159 -0
- package/lib/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
- package/lib/owlly/geometries/ExtrudeGeometry2.js +210 -0
- package/lib/owlly/index.d.ts +13 -0
- package/lib/owlly/index.js +16 -0
- package/lib/owlly/overlay/canvas-overlay.d.ts +96 -0
- package/lib/owlly/overlay/canvas-overlay.js +510 -0
- package/lib/owlly/overlay/css-2d-overlay.d.ts +14 -0
- package/lib/owlly/overlay/css-2d-overlay.js +35 -0
- package/lib/owlly/overlay/css-3d-overlay.d.ts +16 -0
- package/lib/owlly/overlay/css-3d-overlay.js +36 -0
- package/lib/owlly/overlay/index.d.ts +6 -0
- package/lib/owlly/overlay/index.js +11 -0
- package/lib/owlly/overlay/label-overlay.d.ts +62 -0
- package/lib/owlly/overlay/label-overlay.js +328 -0
- package/lib/owlly/overlay/overlay.d.ts +14 -0
- package/lib/owlly/overlay/overlay.js +4 -0
- package/lib/owlly/overlay/path-overlay.d.ts +39 -0
- package/lib/owlly/overlay/path-overlay.js +124 -0
- package/lib/owlly/overlay/path-overlay2.d.ts +35 -0
- package/lib/owlly/overlay/path-overlay2.js +118 -0
- package/lib/owlly/overlay/poi-overlay-3d.d.ts +278 -0
- package/lib/owlly/overlay/poi-overlay-3d.js +1432 -0
- package/lib/owlly/overlay/poi-overlay.d.ts +277 -0
- package/lib/owlly/overlay/poi-overlay.js +1411 -0
- package/lib/owlly/owlly-2d/index.d.ts +28 -0
- package/lib/owlly/owlly-2d/index.js +92 -0
- package/lib/owlly/screen/index.d.ts +1 -0
- package/lib/owlly/screen/index.js +1 -0
- package/lib/owlly/screen/screen.d.ts +73 -0
- package/lib/owlly/screen/screen.js +236 -0
- package/lib/owlly/stage/externals.d.ts +19 -0
- package/lib/owlly/stage/externals.js +24 -0
- package/lib/owlly/stage/index.d.ts +4 -0
- package/lib/owlly/stage/index.js +6 -0
- package/lib/owlly/stage/owlly.d.ts +38 -0
- package/lib/owlly/stage/owlly.js +168 -0
- package/lib/owlly/stage/stage.d.ts +108 -0
- package/lib/owlly/stage/stage.js +234 -0
- package/lib/owlly/utils/alignment-utils.d.ts +20 -0
- package/lib/owlly/utils/alignment-utils.js +63 -0
- package/lib/owlly/utils/basic-calc.d.ts +18 -0
- package/lib/owlly/utils/basic-calc.js +129 -0
- package/lib/owlly/utils/basic-tools.d.ts +71 -0
- package/lib/owlly/utils/basic-tools.js +235 -0
- package/lib/owlly/utils/bvh-tree.d.ts +105 -0
- package/lib/owlly/utils/bvh-tree.js +539 -0
- package/lib/owlly/utils/camera.d.ts +37 -0
- package/lib/owlly/utils/camera.js +50 -0
- package/lib/owlly/utils/cube-texture-cache.d.ts +25 -0
- package/lib/owlly/utils/cube-texture-cache.js +143 -0
- package/lib/owlly/utils/device-utils.d.ts +18 -0
- package/lib/owlly/utils/device-utils.js +41 -0
- package/lib/owlly/utils/environment-utils.d.ts +37 -0
- package/lib/owlly/utils/environment-utils.js +73 -0
- package/lib/owlly/utils/event-hub.d.ts +50 -0
- package/lib/owlly/utils/event-hub.js +106 -0
- package/lib/owlly/utils/events.d.ts +219 -0
- package/lib/owlly/utils/events.js +219 -0
- package/lib/owlly/utils/geometry-utils.d.ts +119 -0
- package/lib/owlly/utils/geometry-utils.js +622 -0
- package/lib/owlly/utils/helper.d.ts +6 -0
- package/lib/owlly/utils/helper.js +24 -0
- package/lib/owlly/utils/index.d.ts +14 -0
- package/lib/owlly/utils/index.js +17 -0
- package/lib/owlly/utils/lru-cache.d.ts +26 -0
- package/lib/owlly/utils/lru-cache.js +109 -0
- package/lib/owlly/utils/map-utils.d.ts +7 -0
- package/lib/owlly/utils/map-utils.js +52 -0
- package/lib/owlly/utils/number-utils.d.ts +8 -0
- package/lib/owlly/utils/number-utils.js +72 -0
- package/lib/owlly/utils/panorama-model-util.d.ts +46 -0
- package/lib/owlly/utils/panorama-model-util.js +245 -0
- package/lib/owlly/utils/path-utils.d.ts +80 -0
- package/lib/owlly/utils/path-utils.js +728 -0
- package/lib/owlly/utils/svgutils.d.ts +138 -0
- package/lib/owlly/utils/svgutils.js +561 -0
- package/lib/owlly/utils/texture-cache.d.ts +29 -0
- package/lib/owlly/utils/texture-cache.js +115 -0
- package/lib/owlly/utils/tile-util.d.ts +187 -0
- package/lib/owlly/utils/tile-util.js +456 -0
- package/lib/owlly/utils/time-profiler.d.ts +21 -0
- package/lib/owlly/utils/time-profiler.js +48 -0
- package/lib/owlly/view/camera-view.d.ts +35 -0
- package/lib/owlly/view/camera-view.js +101 -0
- package/lib/owlly/view/index.d.ts +3 -0
- package/lib/owlly/view/index.js +5 -0
- package/lib/owlly/view/orthographic-view.d.ts +40 -0
- package/lib/owlly/view/orthographic-view.js +94 -0
- package/lib/owlly/view/perspective-view.d.ts +40 -0
- package/lib/owlly/view/perspective-view.js +95 -0
- package/lib/owlly/view/svg-map-view.d.ts +46 -0
- package/lib/owlly/view/svg-map-view.js +144 -0
- package/lib/owlly/view/view.d.ts +146 -0
- package/lib/owlly/view/view.js +317 -0
- package/lib/prod/owlly.esm.js +93462 -0
- package/lib/prod/owlly.esm.js.map +1 -0
- package/lib/prod/owlly.esm.min.js +54 -0
- package/lib/prod/owlly.iife.js +93560 -0
- package/lib/prod/owlly.iife.js.map +1 -0
- package/lib/prod/owlly.iife.min.js +69 -0
- package/lib/prod/owlly.miniapp.js +73845 -0
- package/lib/prod/owlly.miniapp.js.map +1 -0
- package/lib/prod/owlly.miniapp.min.js +63 -0
- package/lib/prod/src/external/lines/line-geometry.d.ts +9 -0
- package/lib/prod/src/external/lines/line-material.d.ts +10 -0
- package/lib/prod/src/external/lines/line-segments-2.d.ts +7 -0
- package/lib/prod/src/external/lines/line-segments-geometry.d.ts +15 -0
- package/lib/prod/src/external/loaders/gltf-loader.d.ts +77 -0
- package/lib/prod/src/external/orbit-controls.d.ts +44 -0
- package/lib/prod/src/external/renderers/css-2d-renderer.d.ts +16 -0
- package/lib/prod/src/external/renderers/css-3d-renderer.d.ts +18 -0
- package/lib/prod/src/external/transform-controls.d.ts +106 -0
- package/lib/prod/src/external/util/buffer-geometry-utils.d.ts +45 -0
- package/lib/prod/src/owlly/controller/aerial-element-controller.d.ts +65 -0
- package/lib/prod/src/owlly/controller/basic-controller.d.ts +324 -0
- package/lib/prod/src/owlly/controller/camera-controller.d.ts +37 -0
- package/lib/prod/src/owlly/controller/controller.d.ts +61 -0
- package/lib/prod/src/owlly/controller/index.d.ts +2 -0
- package/lib/prod/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
- package/lib/prod/src/owlly/controller/orbit-control.d.ts +147 -0
- package/lib/prod/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
- package/lib/prod/src/owlly/controller/panorama-controller.d.ts +441 -0
- package/lib/prod/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
- package/lib/prod/src/owlly/controller/plane-controller.d.ts +43 -0
- package/lib/prod/src/owlly/controller/texture-controller.d.ts +183 -0
- package/lib/prod/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
- package/lib/prod/src/owlly/controller/transform-controller.d.ts +106 -0
- package/lib/prod/src/owlly/element/bottom-nav-element.d.ts +65 -0
- package/lib/prod/src/owlly/element/camera.d.ts +82 -0
- package/lib/prod/src/owlly/element/dom-2d-element.d.ts +35 -0
- package/lib/prod/src/owlly/element/dom-3d-element.d.ts +27 -0
- package/lib/prod/src/owlly/element/dom-label-2d.d.ts +116 -0
- package/lib/prod/src/owlly/element/element.d.ts +53 -0
- package/lib/prod/src/owlly/element/floor-model.d.ts +83 -0
- package/lib/prod/src/owlly/element/gif-kit/Gif.d.ts +96 -0
- package/lib/prod/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
- package/lib/prod/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
- package/lib/prod/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
- package/lib/prod/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
- package/lib/prod/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
- package/lib/prod/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
- package/lib/prod/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
- package/lib/prod/src/owlly/element/gltf-mesh-element.d.ts +31 -0
- package/lib/prod/src/owlly/element/index.d.ts +6 -0
- package/lib/prod/src/owlly/element/map-kit/area.d.ts +24 -0
- package/lib/prod/src/owlly/element/map-kit/block-set.d.ts +39 -0
- package/lib/prod/src/owlly/element/map-kit/block.d.ts +77 -0
- package/lib/prod/src/owlly/element/map-kit/index.d.ts +3 -0
- package/lib/prod/src/owlly/element/map-kit/shape.d.ts +131 -0
- package/lib/prod/src/owlly/element/mesh-element.d.ts +22 -0
- package/lib/prod/src/owlly/element/mesh-line-2d.d.ts +82 -0
- package/lib/prod/src/owlly/element/meshline-o.d.ts +64 -0
- package/lib/prod/src/owlly/element/panorama-group.d.ts +241 -0
- package/lib/prod/src/owlly/element/panorama.d.ts +132 -0
- package/lib/prod/src/owlly/element/path-group.d.ts +69 -0
- package/lib/prod/src/owlly/element/path.d.ts +99 -0
- package/lib/prod/src/owlly/element/placeable-2d.d.ts +158 -0
- package/lib/prod/src/owlly/element/polygon-mesh.d.ts +107 -0
- package/lib/prod/src/owlly/element/ring-element.d.ts +79 -0
- package/lib/prod/src/owlly/element/sphere-mesh.d.ts +28 -0
- package/lib/prod/src/owlly/element/svg-floor-model.d.ts +22 -0
- package/lib/prod/src/owlly/element/svg-floors.d.ts +27 -0
- package/lib/prod/src/owlly/element/tile-panorama-group.d.ts +335 -0
- package/lib/prod/src/owlly/element/tile-panorama.d.ts +162 -0
- package/lib/prod/src/owlly/element/tile-plane.d.ts +114 -0
- package/lib/prod/src/owlly/element/video-element.d.ts +33 -0
- package/lib/prod/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
- package/lib/prod/src/owlly/index.d.ts +13 -0
- package/lib/prod/src/owlly/overlay/canvas-overlay.d.ts +96 -0
- package/lib/prod/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
- package/lib/prod/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
- package/lib/prod/src/owlly/overlay/index.d.ts +5 -0
- package/lib/prod/src/owlly/overlay/label-overlay.d.ts +62 -0
- package/lib/prod/src/owlly/overlay/overlay.d.ts +14 -0
- package/lib/prod/src/owlly/overlay/path-overlay.d.ts +39 -0
- package/lib/prod/src/owlly/overlay/path-overlay2.d.ts +35 -0
- package/lib/prod/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
- package/lib/prod/src/owlly/overlay/poi-overlay.d.ts +277 -0
- package/lib/prod/src/owlly/owlly-2d/index.d.ts +28 -0
- package/lib/prod/src/owlly/screen/index.d.ts +1 -0
- package/lib/prod/src/owlly/screen/screen.d.ts +73 -0
- package/lib/prod/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
- package/lib/prod/src/owlly/stage/externals.d.ts +19 -0
- package/lib/prod/src/owlly/stage/index.d.ts +3 -0
- package/lib/prod/src/owlly/stage/owlly.d.ts +38 -0
- package/lib/prod/src/owlly/stage/stage.d.ts +108 -0
- package/lib/prod/src/owlly/utils/alignment-utils.d.ts +20 -0
- package/lib/prod/src/owlly/utils/basic-calc.d.ts +18 -0
- package/lib/prod/src/owlly/utils/basic-tools.d.ts +71 -0
- package/lib/prod/src/owlly/utils/bvh-tree.d.ts +105 -0
- package/lib/prod/src/owlly/utils/camera.d.ts +37 -0
- package/lib/prod/src/owlly/utils/cube-texture-cache.d.ts +25 -0
- package/lib/prod/src/owlly/utils/device-utils.d.ts +18 -0
- package/lib/prod/src/owlly/utils/environment-utils.d.ts +37 -0
- package/lib/prod/src/owlly/utils/event-hub.d.ts +50 -0
- package/lib/prod/src/owlly/utils/events.d.ts +219 -0
- package/lib/prod/src/owlly/utils/geometry-utils.d.ts +119 -0
- package/lib/prod/src/owlly/utils/helper.d.ts +6 -0
- package/lib/prod/src/owlly/utils/index.d.ts +13 -0
- package/lib/prod/src/owlly/utils/lru-cache.d.ts +26 -0
- package/lib/prod/src/owlly/utils/map-utils.d.ts +7 -0
- package/lib/prod/src/owlly/utils/number-utils.d.ts +8 -0
- package/lib/prod/src/owlly/utils/panorama-model-util.d.ts +46 -0
- package/lib/prod/src/owlly/utils/path-utils.d.ts +80 -0
- package/lib/prod/src/owlly/utils/svgutils.d.ts +138 -0
- package/lib/prod/src/owlly/utils/texture-cache.d.ts +29 -0
- package/lib/prod/src/owlly/utils/tile-util.d.ts +187 -0
- package/lib/prod/src/owlly/utils/time-profiler.d.ts +21 -0
- package/lib/prod/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
- package/lib/prod/src/owlly/view/camera-view.d.ts +35 -0
- package/lib/prod/src/owlly/view/index.d.ts +3 -0
- package/lib/prod/src/owlly/view/orthographic-view.d.ts +40 -0
- package/lib/prod/src/owlly/view/perspective-view.d.ts +40 -0
- package/lib/prod/src/owlly/view/svg-map-view.d.ts +46 -0
- package/lib/prod/src/owlly/view/view.d.ts +146 -0
- package/lib/src/owlly/controller/texture-controller.d.ts +3 -1
- package/lib/src/owlly/controller/texture-controller.js +16 -1
- package/lib/src/owlly/controller/texture-controller.js.map +1 -1
- package/lib/src/owlly/controller/tile-panorama-controller.js +4 -0
- package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -1
- package/lib/src/owlly/element/tile-panorama.d.ts +1 -0
- package/lib/src/owlly/element/tile-panorama.js +16 -3
- package/lib/src/owlly/element/tile-panorama.js.map +1 -1
- package/lib/src/owlly/element/tile-plane.d.ts +9 -0
- package/lib/src/owlly/element/tile-plane.js +27 -0
- package/lib/src/owlly/element/tile-plane.js.map +1 -1
- package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -1
- package/lib/src/owlly/overlay/poi-overlay.js.map +1 -1
- package/lib/src/owlly/stage/owlly.js +7 -1
- package/lib/src/owlly/stage/owlly.js.map +1 -1
- package/lib/src/owlly/stage/stage.js +2 -0
- package/lib/src/owlly/stage/stage.js.map +1 -1
- package/lib/src/web/main.rpeng.mes.plane.js.map +1 -1
- package/package.json +16 -7
- package/src/owlly/controller/texture-controller.ts +18 -1
- package/src/owlly/controller/tile-panorama-controller.ts +3 -1
- package/src/owlly/element/tile-panorama.ts +14 -0
- package/src/owlly/element/tile-plane.ts +26 -0
- package/src/owlly/overlay/poi-overlay-3d.ts +0 -4
- package/src/owlly/overlay/poi-overlay.ts +0 -4
- package/src/owlly/stage/owlly.ts +6 -1
- package/src/owlly/stage/stage.ts +2 -0
- package/src/web/main.rpeng.mes.plane.ts +0 -6
|
@@ -0,0 +1,2318 @@
|
|
|
1
|
+
/* eslint-disable max-len, no-continue, @typescript-eslint/no-explicit-any, no-underscore-dangle, func-names, @typescript-eslint/no-this-alias, no-console, consistent-return, no-param-reassign, prefer-destructuring, no-multi-assign, guard-for-in, no-shadow, no-restricted-syntax, no-plusplus, no-restricted-globals, new-cap */
|
|
2
|
+
import { Externals, NS_THREE } from '../../owlly/stage/externals';
|
|
3
|
+
import { Env, EnvironmentUtils } from '../../owlly/utils/environment-utils';
|
|
4
|
+
const EXTENSIONS = {
|
|
5
|
+
KHR_BINARY_GLTF: 'KHR_binary_glTF',
|
|
6
|
+
KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
|
|
7
|
+
KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
|
|
8
|
+
KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
|
|
9
|
+
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
|
|
10
|
+
KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
|
|
11
|
+
KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
|
|
12
|
+
KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
|
|
13
|
+
KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
|
|
14
|
+
KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
|
|
15
|
+
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
16
|
+
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
17
|
+
};
|
|
18
|
+
/** ****************************** */
|
|
19
|
+
/** ******** INTERNALS *********** */
|
|
20
|
+
/** ****************************** */
|
|
21
|
+
/* CONSTANTS */
|
|
22
|
+
const WEBGL_CONSTANTS = {
|
|
23
|
+
FLOAT: 5126,
|
|
24
|
+
// FLOAT_MAT2: 35674,
|
|
25
|
+
FLOAT_MAT3: 35675,
|
|
26
|
+
FLOAT_MAT4: 35676,
|
|
27
|
+
FLOAT_VEC2: 35664,
|
|
28
|
+
FLOAT_VEC3: 35665,
|
|
29
|
+
FLOAT_VEC4: 35666,
|
|
30
|
+
LINEAR: 9729,
|
|
31
|
+
REPEAT: 10497,
|
|
32
|
+
SAMPLER_2D: 35678,
|
|
33
|
+
POINTS: 0,
|
|
34
|
+
LINES: 1,
|
|
35
|
+
LINE_LOOP: 2,
|
|
36
|
+
LINE_STRIP: 3,
|
|
37
|
+
TRIANGLES: 4,
|
|
38
|
+
TRIANGLE_STRIP: 5,
|
|
39
|
+
TRIANGLE_FAN: 6,
|
|
40
|
+
UNSIGNED_BYTE: 5121,
|
|
41
|
+
UNSIGNED_SHORT: 5123,
|
|
42
|
+
};
|
|
43
|
+
const WEBGL_COMPONENT_TYPES = {
|
|
44
|
+
5120: Int8Array,
|
|
45
|
+
5121: Uint8Array,
|
|
46
|
+
5122: Int16Array,
|
|
47
|
+
5123: Uint16Array,
|
|
48
|
+
5125: Uint32Array,
|
|
49
|
+
5126: Float32Array,
|
|
50
|
+
};
|
|
51
|
+
const WEBGL_FILTERS = {
|
|
52
|
+
9728: NS_THREE.NearestFilter,
|
|
53
|
+
9729: NS_THREE.LinearFilter,
|
|
54
|
+
9984: NS_THREE.NearestMipmapNearestFilter,
|
|
55
|
+
9985: NS_THREE.LinearMipmapNearestFilter,
|
|
56
|
+
9986: NS_THREE.NearestMipmapLinearFilter,
|
|
57
|
+
9987: NS_THREE.LinearMipmapLinearFilter,
|
|
58
|
+
};
|
|
59
|
+
const WEBGL_WRAPPINGS = {
|
|
60
|
+
33071: NS_THREE.ClampToEdgeWrapping,
|
|
61
|
+
33648: NS_THREE.MirroredRepeatWrapping,
|
|
62
|
+
10497: NS_THREE.RepeatWrapping,
|
|
63
|
+
};
|
|
64
|
+
const WEBGL_TYPE_SIZES = {
|
|
65
|
+
SCALAR: 1,
|
|
66
|
+
VEC2: 2,
|
|
67
|
+
VEC3: 3,
|
|
68
|
+
VEC4: 4,
|
|
69
|
+
MAT2: 4,
|
|
70
|
+
MAT3: 9,
|
|
71
|
+
MAT4: 16,
|
|
72
|
+
};
|
|
73
|
+
const ATTRIBUTES = {
|
|
74
|
+
POSITION: 'position',
|
|
75
|
+
NORMAL: 'normal',
|
|
76
|
+
TANGENT: 'tangent',
|
|
77
|
+
TEXCOORD_0: 'uv',
|
|
78
|
+
TEXCOORD_1: 'uv2',
|
|
79
|
+
COLOR_0: 'color',
|
|
80
|
+
WEIGHTS_0: 'skinWeight',
|
|
81
|
+
JOINTS_0: 'skinIndex',
|
|
82
|
+
};
|
|
83
|
+
const PATH_PROPERTIES = {
|
|
84
|
+
scale: 'scale',
|
|
85
|
+
translation: 'position',
|
|
86
|
+
rotation: 'quaternion',
|
|
87
|
+
weights: 'morphTargetInfluences',
|
|
88
|
+
};
|
|
89
|
+
const INTERPOLATION = {
|
|
90
|
+
CUBICSPLINE: undefined,
|
|
91
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
92
|
+
LINEAR: NS_THREE.InterpolateLinear,
|
|
93
|
+
STEP: NS_THREE.InterpolateDiscrete,
|
|
94
|
+
};
|
|
95
|
+
const ALPHA_MODES = {
|
|
96
|
+
OPAQUE: 'OPAQUE',
|
|
97
|
+
MASK: 'MASK',
|
|
98
|
+
BLEND: 'BLEND',
|
|
99
|
+
};
|
|
100
|
+
/* UTILITY FUNCTIONS */
|
|
101
|
+
function resolveURL(url, path) {
|
|
102
|
+
// Invalid URL
|
|
103
|
+
if (typeof url !== 'string' || url === '')
|
|
104
|
+
return '';
|
|
105
|
+
// Host Relative URL
|
|
106
|
+
if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
|
|
107
|
+
path = path.replace(/(^https?:\/\/[^/]+).*/i, '$1');
|
|
108
|
+
}
|
|
109
|
+
// Absolute URL http://,https://,//
|
|
110
|
+
if (/^(https?:)?\/\//i.test(url))
|
|
111
|
+
return url;
|
|
112
|
+
// Data URI
|
|
113
|
+
if (/^data:.*,.*$/i.test(url))
|
|
114
|
+
return url;
|
|
115
|
+
// Blob URL
|
|
116
|
+
if (/^blob:.*$/i.test(url))
|
|
117
|
+
return url;
|
|
118
|
+
// Relative URL
|
|
119
|
+
return path + url;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
123
|
+
*/
|
|
124
|
+
function createDefaultMaterial(cache) {
|
|
125
|
+
const { THREE } = Externals.getInstance();
|
|
126
|
+
if (cache.DefaultMaterial === undefined) {
|
|
127
|
+
cache.DefaultMaterial = new THREE.MeshStandardMaterial({
|
|
128
|
+
color: 0xFFFFFF,
|
|
129
|
+
emissive: 0x000000,
|
|
130
|
+
metalness: 1,
|
|
131
|
+
roughness: 1,
|
|
132
|
+
transparent: false,
|
|
133
|
+
depthTest: true,
|
|
134
|
+
side: THREE.FrontSide,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return cache.DefaultMaterial;
|
|
138
|
+
}
|
|
139
|
+
function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {
|
|
140
|
+
// Add unknown glTF extensions to an object's userData.
|
|
141
|
+
for (const name in objectDef.extensions) {
|
|
142
|
+
if (knownExtensions[name] === undefined) {
|
|
143
|
+
object.userData.gltfExtensions = object.userData.gltfExtensions || {};
|
|
144
|
+
object.userData.gltfExtensions[name] = objectDef.extensions[name];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @param {Object3D|Material|BufferGeometry} object
|
|
150
|
+
* @param {GLTF.definition} gltfDef
|
|
151
|
+
*/
|
|
152
|
+
function assignExtrasToUserData(object, gltfDef) {
|
|
153
|
+
if (gltfDef.extras !== undefined) {
|
|
154
|
+
if (typeof gltfDef.extras === 'object') {
|
|
155
|
+
Object.assign(object.userData, gltfDef.extras);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, ${gltfDef.extras}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
164
|
+
*
|
|
165
|
+
* @param {BufferGeometry} geometry
|
|
166
|
+
* @param {Array<GLTF.Target>} targets
|
|
167
|
+
* @param {GLTFParser} parser
|
|
168
|
+
* @return {Promise<BufferGeometry>}
|
|
169
|
+
*/
|
|
170
|
+
function addMorphTargets(geometry, targets, parser) {
|
|
171
|
+
let hasMorphPosition = false;
|
|
172
|
+
let hasMorphNormal = false;
|
|
173
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
174
|
+
const target = targets[i];
|
|
175
|
+
if (target.POSITION !== undefined)
|
|
176
|
+
hasMorphPosition = true;
|
|
177
|
+
if (target.NORMAL !== undefined)
|
|
178
|
+
hasMorphNormal = true;
|
|
179
|
+
if (hasMorphPosition && hasMorphNormal)
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (!hasMorphPosition && !hasMorphNormal)
|
|
183
|
+
return Promise.resolve(geometry);
|
|
184
|
+
const pendingPositionAccessors = [];
|
|
185
|
+
const pendingNormalAccessors = [];
|
|
186
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
187
|
+
const target = targets[i];
|
|
188
|
+
if (hasMorphPosition) {
|
|
189
|
+
const pendingAccessor = target.POSITION !== undefined
|
|
190
|
+
? parser.getDependency('accessor', target.POSITION)
|
|
191
|
+
: geometry.attributes.position;
|
|
192
|
+
pendingPositionAccessors.push(pendingAccessor);
|
|
193
|
+
}
|
|
194
|
+
if (hasMorphNormal) {
|
|
195
|
+
const pendingAccessor = target.NORMAL !== undefined
|
|
196
|
+
? parser.getDependency('accessor', target.NORMAL)
|
|
197
|
+
: geometry.attributes.normal;
|
|
198
|
+
pendingNormalAccessors.push(pendingAccessor);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return Promise.all([
|
|
202
|
+
Promise.all(pendingPositionAccessors),
|
|
203
|
+
Promise.all(pendingNormalAccessors),
|
|
204
|
+
]).then((accessors) => {
|
|
205
|
+
const morphPositions = accessors[0];
|
|
206
|
+
const morphNormals = accessors[1];
|
|
207
|
+
if (hasMorphPosition)
|
|
208
|
+
geometry.morphAttributes.position = morphPositions;
|
|
209
|
+
if (hasMorphNormal)
|
|
210
|
+
geometry.morphAttributes.normal = morphNormals;
|
|
211
|
+
geometry.morphTargetsRelative = true;
|
|
212
|
+
return geometry;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @param {Mesh} mesh
|
|
217
|
+
* @param {GLTF.Mesh} meshDef
|
|
218
|
+
*/
|
|
219
|
+
function updateMorphTargets(mesh, meshDef) {
|
|
220
|
+
mesh.updateMorphTargets();
|
|
221
|
+
if (meshDef.weights !== undefined) {
|
|
222
|
+
for (let i = 0, il = meshDef.weights.length; i < il; i++) {
|
|
223
|
+
mesh.morphTargetInfluences[i] = meshDef.weights[i];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// .extras has user-defined data, so check that .extras.targetNames is an array.
|
|
227
|
+
if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {
|
|
228
|
+
const { targetNames } = meshDef.extras;
|
|
229
|
+
if (mesh.morphTargetInfluences.length === targetNames.length) {
|
|
230
|
+
mesh.morphTargetDictionary = {};
|
|
231
|
+
for (let i = 0, il = targetNames.length; i < il; i++) {
|
|
232
|
+
mesh.morphTargetDictionary[targetNames[i]] = i;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
console.warn('THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function createAttributesKey(attributes) {
|
|
241
|
+
let attributesKey = '';
|
|
242
|
+
const keys = Object.keys(attributes).sort();
|
|
243
|
+
for (let i = 0, il = keys.length; i < il; i++) {
|
|
244
|
+
attributesKey += `${keys[i]}:${attributes[keys[i]]};`;
|
|
245
|
+
}
|
|
246
|
+
return attributesKey;
|
|
247
|
+
}
|
|
248
|
+
function createPrimitiveKey(primitiveDef) {
|
|
249
|
+
const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];
|
|
250
|
+
let geometryKey;
|
|
251
|
+
if (dracoExtension) {
|
|
252
|
+
geometryKey = `draco:${dracoExtension.bufferView}:${dracoExtension.indices}:${createAttributesKey(dracoExtension.attributes)}`;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
geometryKey = `${primitiveDef.indices}:${createAttributesKey(primitiveDef.attributes)}:${primitiveDef.mode}`;
|
|
256
|
+
}
|
|
257
|
+
return geometryKey;
|
|
258
|
+
}
|
|
259
|
+
class GLTFRegistry {
|
|
260
|
+
constructor() {
|
|
261
|
+
this.objects = {};
|
|
262
|
+
}
|
|
263
|
+
get(key) {
|
|
264
|
+
return this.objects[key];
|
|
265
|
+
}
|
|
266
|
+
add(key, object) {
|
|
267
|
+
this.objects[key] = object;
|
|
268
|
+
}
|
|
269
|
+
remove(key) {
|
|
270
|
+
delete this.objects[key];
|
|
271
|
+
}
|
|
272
|
+
removeAll() {
|
|
273
|
+
this.objects = {};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
class GLTFLightsExtension {
|
|
277
|
+
constructor(parser) {
|
|
278
|
+
this.parser = parser;
|
|
279
|
+
this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
|
|
280
|
+
// Object3D instance caches
|
|
281
|
+
this.cache = { refs: {}, uses: {} };
|
|
282
|
+
}
|
|
283
|
+
_markDefs() {
|
|
284
|
+
const { parser } = this;
|
|
285
|
+
const nodeDefs = this.parser.json.nodes || [];
|
|
286
|
+
for (let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
|
|
287
|
+
const nodeDef = nodeDefs[nodeIndex];
|
|
288
|
+
if (nodeDef.extensions
|
|
289
|
+
&& nodeDef.extensions[this.name]
|
|
290
|
+
&& nodeDef.extensions[this.name].light !== undefined) {
|
|
291
|
+
parser._addNodeRef(this.cache, nodeDef.extensions[this.name].light);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
_loadLight(lightIndex) {
|
|
296
|
+
const { parser } = this;
|
|
297
|
+
const cacheKey = `light:${lightIndex}`;
|
|
298
|
+
let dependency = parser.cache.get(cacheKey);
|
|
299
|
+
if (dependency)
|
|
300
|
+
return dependency;
|
|
301
|
+
const { json } = parser;
|
|
302
|
+
const extensions = (json.extensions && json.extensions[this.name]) || {};
|
|
303
|
+
const lightDefs = extensions.lights || [];
|
|
304
|
+
const lightDef = lightDefs[lightIndex];
|
|
305
|
+
let lightNode;
|
|
306
|
+
const { THREE } = Externals.getInstance();
|
|
307
|
+
const color = new THREE.Color(0xffffff);
|
|
308
|
+
if (lightDef.color !== undefined)
|
|
309
|
+
color.fromArray(lightDef.color);
|
|
310
|
+
const range = lightDef.range !== undefined ? lightDef.range : 0;
|
|
311
|
+
switch (lightDef.type) {
|
|
312
|
+
case 'directional':
|
|
313
|
+
lightNode = new THREE.DirectionalLight(color);
|
|
314
|
+
lightNode.target.position.set(0, 0, -1);
|
|
315
|
+
lightNode.add(lightNode.target);
|
|
316
|
+
break;
|
|
317
|
+
case 'point':
|
|
318
|
+
lightNode = new THREE.PointLight(color);
|
|
319
|
+
lightNode.distance = range;
|
|
320
|
+
break;
|
|
321
|
+
case 'spot':
|
|
322
|
+
lightNode = new THREE.SpotLight(color);
|
|
323
|
+
lightNode.distance = range;
|
|
324
|
+
// Handle spotlight properties.
|
|
325
|
+
lightDef.spot = lightDef.spot || {};
|
|
326
|
+
lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
|
|
327
|
+
lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
|
|
328
|
+
lightNode.angle = lightDef.spot.outerConeAngle;
|
|
329
|
+
lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
|
|
330
|
+
lightNode.target.position.set(0, 0, -1);
|
|
331
|
+
lightNode.add(lightNode.target);
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
throw new Error(`THREE.GLTFLoader: Unexpected light type: ${lightDef.type}`);
|
|
335
|
+
}
|
|
336
|
+
// Some lights (e.g. spot) default to a position other than the origin. Reset the position
|
|
337
|
+
// here, because node-level parsing will only override position if explicitly specified.
|
|
338
|
+
lightNode.position.set(0, 0, 0);
|
|
339
|
+
lightNode.decay = 2;
|
|
340
|
+
if (lightDef.intensity !== undefined)
|
|
341
|
+
lightNode.intensity = lightDef.intensity;
|
|
342
|
+
lightNode.name = parser.createUniqueName(lightDef.name || (`light_${lightIndex}`));
|
|
343
|
+
dependency = Promise.resolve(lightNode);
|
|
344
|
+
parser.cache.add(cacheKey, dependency);
|
|
345
|
+
return dependency;
|
|
346
|
+
}
|
|
347
|
+
createNodeAttachment(nodeIndex) {
|
|
348
|
+
const self = this;
|
|
349
|
+
const { parser } = this;
|
|
350
|
+
const { json } = parser;
|
|
351
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
352
|
+
const lightDef = (nodeDef.extensions && nodeDef.extensions[this.name]) || {};
|
|
353
|
+
const lightIndex = lightDef.light;
|
|
354
|
+
if (lightIndex === undefined)
|
|
355
|
+
return null;
|
|
356
|
+
return this._loadLight(lightIndex).then((light) => parser._getNodeRef(self.cache, lightIndex, light));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
class GLTFMaterialsUnlitExtension {
|
|
360
|
+
constructor() {
|
|
361
|
+
this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
|
|
362
|
+
}
|
|
363
|
+
getMaterialType() {
|
|
364
|
+
const { THREE } = Externals.getInstance();
|
|
365
|
+
return THREE.MeshBasicMaterial;
|
|
366
|
+
}
|
|
367
|
+
extendParams(materialParams, materialDef, parser) {
|
|
368
|
+
const pending = [];
|
|
369
|
+
const { THREE } = Externals.getInstance();
|
|
370
|
+
materialParams.color = new THREE.Color(1.0, 1.0, 1.0);
|
|
371
|
+
materialParams.opacity = 1.0;
|
|
372
|
+
const metallicRoughness = materialDef.pbrMetallicRoughness;
|
|
373
|
+
if (metallicRoughness) {
|
|
374
|
+
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
375
|
+
const array = metallicRoughness.baseColorFactor;
|
|
376
|
+
materialParams.color.fromArray(array);
|
|
377
|
+
materialParams.opacity = array[3];
|
|
378
|
+
}
|
|
379
|
+
if (metallicRoughness.baseColorTexture !== undefined) {
|
|
380
|
+
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return Promise.all(pending);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
class GLTFMaterialsClearcoatExtension {
|
|
387
|
+
constructor(parser) {
|
|
388
|
+
this.parser = parser;
|
|
389
|
+
this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
|
|
390
|
+
}
|
|
391
|
+
getMaterialType(materialIndex) {
|
|
392
|
+
const parser = this.parser;
|
|
393
|
+
const materialDef = parser.json.materials[materialIndex];
|
|
394
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name])
|
|
395
|
+
return null;
|
|
396
|
+
const { THREE } = Externals.getInstance();
|
|
397
|
+
return THREE.MeshPhysicalMaterial;
|
|
398
|
+
}
|
|
399
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
400
|
+
const parser = this.parser;
|
|
401
|
+
const materialDef = parser.json.materials[materialIndex];
|
|
402
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name]) {
|
|
403
|
+
return Promise.resolve();
|
|
404
|
+
}
|
|
405
|
+
const pending = [];
|
|
406
|
+
const extension = materialDef.extensions[this.name];
|
|
407
|
+
const { THREE } = Externals.getInstance();
|
|
408
|
+
if (extension.clearcoatFactor !== undefined) {
|
|
409
|
+
materialParams.clearcoat = extension.clearcoatFactor;
|
|
410
|
+
}
|
|
411
|
+
if (extension.clearcoatTexture !== undefined) {
|
|
412
|
+
pending.push(parser.assignTexture(materialParams, 'clearcoatMap', extension.clearcoatTexture));
|
|
413
|
+
}
|
|
414
|
+
if (extension.clearcoatRoughnessFactor !== undefined) {
|
|
415
|
+
materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
|
|
416
|
+
}
|
|
417
|
+
if (extension.clearcoatRoughnessTexture !== undefined) {
|
|
418
|
+
pending.push(parser.assignTexture(materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture));
|
|
419
|
+
}
|
|
420
|
+
if (extension.clearcoatNormalTexture !== undefined) {
|
|
421
|
+
pending.push(parser.assignTexture(materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture));
|
|
422
|
+
if (extension.clearcoatNormalTexture.scale !== undefined) {
|
|
423
|
+
const scale = extension.clearcoatNormalTexture.scale;
|
|
424
|
+
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
|
|
425
|
+
materialParams.clearcoatNormalScale = new THREE.Vector2(scale, -scale);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return Promise.all(pending);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
class GLTFMaterialsTransmissionExtension {
|
|
432
|
+
constructor(parser) {
|
|
433
|
+
this.parser = parser;
|
|
434
|
+
this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
|
|
435
|
+
}
|
|
436
|
+
getMaterialType(materialIndex) {
|
|
437
|
+
const { parser } = this;
|
|
438
|
+
const materialDef = parser.json.materials[materialIndex];
|
|
439
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name])
|
|
440
|
+
return null;
|
|
441
|
+
const { THREE } = Externals.getInstance();
|
|
442
|
+
return THREE.MeshPhysicalMaterial;
|
|
443
|
+
}
|
|
444
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
445
|
+
const { parser } = this;
|
|
446
|
+
const materialDef = parser.json.materials[materialIndex];
|
|
447
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name]) {
|
|
448
|
+
return Promise.resolve();
|
|
449
|
+
}
|
|
450
|
+
const pending = [];
|
|
451
|
+
const extension = materialDef.extensions[this.name];
|
|
452
|
+
if (extension.transmissionFactor !== undefined) {
|
|
453
|
+
materialParams.transmission = extension.transmissionFactor;
|
|
454
|
+
}
|
|
455
|
+
if (extension.transmissionTexture !== undefined) {
|
|
456
|
+
pending.push(parser.assignTexture(materialParams, 'transmissionMap', extension.transmissionTexture));
|
|
457
|
+
}
|
|
458
|
+
return Promise.all(pending);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
class GLTFTextureBasisUExtension {
|
|
462
|
+
constructor(parser) {
|
|
463
|
+
this.parser = parser;
|
|
464
|
+
this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
|
|
465
|
+
}
|
|
466
|
+
loadTexture(textureIndex) {
|
|
467
|
+
const { parser } = this;
|
|
468
|
+
const { json } = parser;
|
|
469
|
+
const textureDef = json.textures[textureIndex];
|
|
470
|
+
if (!textureDef.extensions || !textureDef.extensions[this.name]) {
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
const extension = textureDef.extensions[this.name];
|
|
474
|
+
const source = json.images[extension.source];
|
|
475
|
+
const loader = parser.options.ktx2Loader;
|
|
476
|
+
if (!loader) {
|
|
477
|
+
if (json.extensionsRequired && json.extensionsRequired.indexOf(this.name) >= 0) {
|
|
478
|
+
throw new Error('THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures');
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
// Assumes that the extension is optional and that a fallback texture is present
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return parser.loadTextureImage(textureIndex, source, loader);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
class GLTFTextureWebPExtension {
|
|
489
|
+
constructor(parser) {
|
|
490
|
+
this.parser = parser;
|
|
491
|
+
this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
|
|
492
|
+
this.isSupported = null;
|
|
493
|
+
}
|
|
494
|
+
loadTexture(textureIndex) {
|
|
495
|
+
const { name } = this;
|
|
496
|
+
const { parser } = this;
|
|
497
|
+
const { json } = parser;
|
|
498
|
+
const textureDef = json.textures[textureIndex];
|
|
499
|
+
if (!textureDef.extensions || !textureDef.extensions[name]) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
const extension = textureDef.extensions[name];
|
|
503
|
+
const source = json.images[extension.source];
|
|
504
|
+
let loader = parser.textureLoader;
|
|
505
|
+
if (source.uri) {
|
|
506
|
+
const handler = parser.options.manager.getHandler(source.uri);
|
|
507
|
+
if (handler !== null)
|
|
508
|
+
loader = handler;
|
|
509
|
+
}
|
|
510
|
+
return this.detectSupport().then((isSupported) => {
|
|
511
|
+
if (isSupported)
|
|
512
|
+
return parser.loadTextureImage(textureIndex, source, loader);
|
|
513
|
+
if (json.extensionsRequired && json.extensionsRequired.indexOf(name) >= 0) {
|
|
514
|
+
throw new Error('THREE.GLTFLoader: WebP required by asset but unsupported.');
|
|
515
|
+
}
|
|
516
|
+
// Fall back to PNG or JPEG.
|
|
517
|
+
return parser.loadTexture(textureIndex);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
detectSupport() {
|
|
521
|
+
if (!this.isSupported) {
|
|
522
|
+
this.isSupported = new Promise(((resolve) => {
|
|
523
|
+
const image = new Image();
|
|
524
|
+
// Lossy test image. Support for lossy images doesn't guarantee support for all
|
|
525
|
+
// WebP images, unfortunately.
|
|
526
|
+
image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
|
|
527
|
+
image.onload = image.onerror = function () {
|
|
528
|
+
resolve(image.height === 1);
|
|
529
|
+
};
|
|
530
|
+
}));
|
|
531
|
+
}
|
|
532
|
+
return this.isSupported;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
class GLTFMeshoptCompression {
|
|
536
|
+
constructor(parser) {
|
|
537
|
+
this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION;
|
|
538
|
+
this.parser = parser;
|
|
539
|
+
}
|
|
540
|
+
loadBufferView(index) {
|
|
541
|
+
const { json } = this.parser;
|
|
542
|
+
const bufferView = json.bufferViews[index];
|
|
543
|
+
if (bufferView.extensions && bufferView.extensions[this.name]) {
|
|
544
|
+
const extensionDef = bufferView.extensions[this.name];
|
|
545
|
+
const buffer = this.parser.getDependency('buffer', extensionDef.buffer);
|
|
546
|
+
const decoder = this.parser.options.meshoptDecoder;
|
|
547
|
+
if (!decoder || !decoder.supported) {
|
|
548
|
+
if (json.extensionsRequired && json.extensionsRequired.indexOf(this.name) >= 0) {
|
|
549
|
+
throw new Error('THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files');
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
// Assumes that the extension is optional and that fallback buffer data is present
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return Promise.all([buffer, decoder.ready]).then((res) => {
|
|
557
|
+
const byteOffset = extensionDef.byteOffset || 0;
|
|
558
|
+
const byteLength = extensionDef.byteLength || 0;
|
|
559
|
+
const { count } = extensionDef;
|
|
560
|
+
const stride = extensionDef.byteStride;
|
|
561
|
+
const result = new ArrayBuffer(count * stride);
|
|
562
|
+
const source = new Uint8Array(res[0], byteOffset, byteLength);
|
|
563
|
+
decoder.decodeGltfBuffer(new Uint8Array(result), count, stride, source, extensionDef.mode, extensionDef.filter);
|
|
564
|
+
return result;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/* BINARY EXTENSION */
|
|
571
|
+
const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
|
|
572
|
+
const BINARY_EXTENSION_HEADER_LENGTH = 12;
|
|
573
|
+
const BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 };
|
|
574
|
+
class GLTFBinaryExtension {
|
|
575
|
+
constructor(data) {
|
|
576
|
+
const { THREE } = Externals.getInstance();
|
|
577
|
+
this.name = EXTENSIONS.KHR_BINARY_GLTF;
|
|
578
|
+
this.content = null;
|
|
579
|
+
this.body = null;
|
|
580
|
+
const headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
|
|
581
|
+
this.header = {
|
|
582
|
+
magic: THREE.LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),
|
|
583
|
+
version: headerView.getUint32(4, true),
|
|
584
|
+
length: headerView.getUint32(8, true),
|
|
585
|
+
};
|
|
586
|
+
if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {
|
|
587
|
+
throw new Error('THREE.GLTFLoader: Unsupported glTF-Binary header.');
|
|
588
|
+
}
|
|
589
|
+
else if (this.header.version < 2.0) {
|
|
590
|
+
throw new Error('THREE.GLTFLoader: Legacy binary file detected.');
|
|
591
|
+
}
|
|
592
|
+
const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
|
|
593
|
+
const chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);
|
|
594
|
+
let chunkIndex = 0;
|
|
595
|
+
while (chunkIndex < chunkContentsLength) {
|
|
596
|
+
const chunkLength = chunkView.getUint32(chunkIndex, true);
|
|
597
|
+
chunkIndex += 4;
|
|
598
|
+
const chunkType = chunkView.getUint32(chunkIndex, true);
|
|
599
|
+
chunkIndex += 4;
|
|
600
|
+
if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
|
|
601
|
+
const contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
|
|
602
|
+
this.content = THREE.LoaderUtils.decodeText(contentArray);
|
|
603
|
+
}
|
|
604
|
+
else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
|
|
605
|
+
const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
|
|
606
|
+
this.body = data.slice(byteOffset, byteOffset + chunkLength);
|
|
607
|
+
}
|
|
608
|
+
// Clients must ignore chunks with unknown types.
|
|
609
|
+
chunkIndex += chunkLength;
|
|
610
|
+
}
|
|
611
|
+
if (this.content === null) {
|
|
612
|
+
throw new Error('THREE.GLTFLoader: JSON content not found.');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
class GLTFDracoMeshCompressionExtension {
|
|
617
|
+
constructor(json, dracoLoader) {
|
|
618
|
+
if (!dracoLoader) {
|
|
619
|
+
throw new Error('THREE.GLTFLoader: No DRACOLoader instance provided.');
|
|
620
|
+
}
|
|
621
|
+
this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
|
|
622
|
+
this.json = json;
|
|
623
|
+
this.dracoLoader = dracoLoader;
|
|
624
|
+
this.dracoLoader.preload();
|
|
625
|
+
}
|
|
626
|
+
decodePrimitive(primitive, parser) {
|
|
627
|
+
const { json } = this;
|
|
628
|
+
const { dracoLoader } = this;
|
|
629
|
+
const bufferViewIndex = primitive.extensions[this.name].bufferView;
|
|
630
|
+
const gltfAttributeMap = primitive.extensions[this.name].attributes;
|
|
631
|
+
const threeAttributeMap = {};
|
|
632
|
+
const attributeNormalizedMap = {};
|
|
633
|
+
const attributeTypeMap = {};
|
|
634
|
+
for (const attributeName in gltfAttributeMap) {
|
|
635
|
+
const threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
|
|
636
|
+
threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];
|
|
637
|
+
}
|
|
638
|
+
for (const attributeName in primitive.attributes) {
|
|
639
|
+
const threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
|
|
640
|
+
if (gltfAttributeMap[attributeName] !== undefined) {
|
|
641
|
+
const accessorDef = json.accessors[primitive.attributes[attributeName]];
|
|
642
|
+
const componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
643
|
+
attributeTypeMap[threeAttributeName] = componentType;
|
|
644
|
+
attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return parser.getDependency('bufferView', bufferViewIndex).then((bufferView) => new Promise(((resolve) => {
|
|
648
|
+
dracoLoader.decodeDracoFile(bufferView, (geometry) => {
|
|
649
|
+
for (const attributeName in geometry.attributes) {
|
|
650
|
+
const attribute = geometry.attributes[attributeName];
|
|
651
|
+
const normalized = attributeNormalizedMap[attributeName];
|
|
652
|
+
if (normalized !== undefined)
|
|
653
|
+
attribute.normalized = normalized;
|
|
654
|
+
}
|
|
655
|
+
resolve(geometry);
|
|
656
|
+
}, threeAttributeMap, attributeTypeMap);
|
|
657
|
+
})));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
class GLTFTextureTransformExtension {
|
|
661
|
+
constructor() {
|
|
662
|
+
this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
|
|
663
|
+
}
|
|
664
|
+
extendTexture(texture, transform) {
|
|
665
|
+
texture = texture.clone();
|
|
666
|
+
if (transform.offset !== undefined) {
|
|
667
|
+
texture.offset.fromArray(transform.offset);
|
|
668
|
+
}
|
|
669
|
+
if (transform.rotation !== undefined) {
|
|
670
|
+
texture.rotation = transform.rotation;
|
|
671
|
+
}
|
|
672
|
+
if (transform.scale !== undefined) {
|
|
673
|
+
texture.repeat.fromArray(transform.scale);
|
|
674
|
+
}
|
|
675
|
+
if (transform.texCoord !== undefined) {
|
|
676
|
+
console.warn(`THREE.GLTFLoader: Custom UV sets in "${this.name}" extension not yet supported.`);
|
|
677
|
+
}
|
|
678
|
+
texture.needsUpdate = true;
|
|
679
|
+
return texture;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
class GLTFMeshStandardSGMaterial extends NS_THREE.MeshStandardMaterial {
|
|
683
|
+
constructor(params) {
|
|
684
|
+
super(params);
|
|
685
|
+
this.isGLTFSpecularGlossinessMaterial = true;
|
|
686
|
+
// various chunks that need replacing
|
|
687
|
+
const specularMapParsFragmentChunk = [
|
|
688
|
+
'#ifdef USE_SPECULARMAP',
|
|
689
|
+
' uniform sampler2D specularMap;',
|
|
690
|
+
'#endif',
|
|
691
|
+
].join('\n');
|
|
692
|
+
const glossinessMapParsFragmentChunk = [
|
|
693
|
+
'#ifdef USE_GLOSSINESSMAP',
|
|
694
|
+
' uniform sampler2D glossinessMap;',
|
|
695
|
+
'#endif',
|
|
696
|
+
].join('\n');
|
|
697
|
+
const specularMapFragmentChunk = [
|
|
698
|
+
'vec3 specularFactor = specular;',
|
|
699
|
+
'#ifdef USE_SPECULARMAP',
|
|
700
|
+
' vec4 texelSpecular = texture2D( specularMap, vUv );',
|
|
701
|
+
' texelSpecular = sRGBToLinear( texelSpecular );',
|
|
702
|
+
' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
703
|
+
' specularFactor *= texelSpecular.rgb;',
|
|
704
|
+
'#endif',
|
|
705
|
+
].join('\n');
|
|
706
|
+
const glossinessMapFragmentChunk = [
|
|
707
|
+
'float glossinessFactor = glossiness;',
|
|
708
|
+
'#ifdef USE_GLOSSINESSMAP',
|
|
709
|
+
' vec4 texelGlossiness = texture2D( glossinessMap, vUv );',
|
|
710
|
+
' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
711
|
+
' glossinessFactor *= texelGlossiness.a;',
|
|
712
|
+
'#endif',
|
|
713
|
+
].join('\n');
|
|
714
|
+
const lightPhysicalFragmentChunk = [
|
|
715
|
+
'PhysicalMaterial material;',
|
|
716
|
+
'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
|
|
717
|
+
'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
|
|
718
|
+
'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
|
|
719
|
+
'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.',
|
|
720
|
+
'material.specularRoughness += geometryRoughness;',
|
|
721
|
+
'material.specularRoughness = min( material.specularRoughness, 1.0 );',
|
|
722
|
+
'material.specularColor = specularFactor;',
|
|
723
|
+
].join('\n');
|
|
724
|
+
const { THREE } = Externals.getInstance();
|
|
725
|
+
const uniforms = {
|
|
726
|
+
specular: { value: new THREE.Color().setHex(0xffffff) },
|
|
727
|
+
glossiness: { value: 1 },
|
|
728
|
+
specularMap: { value: null },
|
|
729
|
+
glossinessMap: { value: null },
|
|
730
|
+
};
|
|
731
|
+
this._extraUniforms = uniforms;
|
|
732
|
+
this.onBeforeCompile = function (shader) {
|
|
733
|
+
for (const uniformName in uniforms) {
|
|
734
|
+
shader.uniforms[uniformName] = uniforms[uniformName];
|
|
735
|
+
}
|
|
736
|
+
shader.fragmentShader = shader.fragmentShader
|
|
737
|
+
.replace('uniform float roughness;', 'uniform vec3 specular;')
|
|
738
|
+
.replace('uniform float metalness;', 'uniform float glossiness;')
|
|
739
|
+
.replace('#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk)
|
|
740
|
+
.replace('#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk)
|
|
741
|
+
.replace('#include <roughnessmap_fragment>', specularMapFragmentChunk)
|
|
742
|
+
.replace('#include <metalnessmap_fragment>', glossinessMapFragmentChunk)
|
|
743
|
+
.replace('#include <lights_physical_fragment>', lightPhysicalFragmentChunk);
|
|
744
|
+
};
|
|
745
|
+
Object.defineProperties(this, {
|
|
746
|
+
specular: {
|
|
747
|
+
get() {
|
|
748
|
+
return uniforms.specular.value;
|
|
749
|
+
},
|
|
750
|
+
set(v) {
|
|
751
|
+
uniforms.specular.value = v;
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
specularMap: {
|
|
755
|
+
get() {
|
|
756
|
+
return uniforms.specularMap.value;
|
|
757
|
+
},
|
|
758
|
+
set(v) {
|
|
759
|
+
uniforms.specularMap.value = v;
|
|
760
|
+
if (v) {
|
|
761
|
+
this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
delete this.defines.USE_SPECULARMAP;
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
glossiness: {
|
|
769
|
+
get() {
|
|
770
|
+
return uniforms.glossiness.value;
|
|
771
|
+
},
|
|
772
|
+
set(v) {
|
|
773
|
+
uniforms.glossiness.value = v;
|
|
774
|
+
},
|
|
775
|
+
},
|
|
776
|
+
glossinessMap: {
|
|
777
|
+
get() {
|
|
778
|
+
return uniforms.glossinessMap.value;
|
|
779
|
+
},
|
|
780
|
+
set(v) {
|
|
781
|
+
uniforms.glossinessMap.value = v;
|
|
782
|
+
if (v) {
|
|
783
|
+
this.defines.USE_GLOSSINESSMAP = '';
|
|
784
|
+
this.defines.USE_UV = '';
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
delete this.defines.USE_GLOSSINESSMAP;
|
|
788
|
+
delete this.defines.USE_UV;
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
});
|
|
793
|
+
delete this.metalness;
|
|
794
|
+
delete this.roughness;
|
|
795
|
+
delete this.metalnessMap;
|
|
796
|
+
delete this.roughnessMap;
|
|
797
|
+
this.setValues(params);
|
|
798
|
+
}
|
|
799
|
+
copy(source) {
|
|
800
|
+
const { THREE } = Externals.getInstance();
|
|
801
|
+
THREE.MeshStandardMaterial.prototype.copy.call(this, source);
|
|
802
|
+
this.specularMap = source.specularMap;
|
|
803
|
+
this.specular.copy(source.specular);
|
|
804
|
+
this.glossinessMap = source.glossinessMap;
|
|
805
|
+
this.glossiness = source.glossiness;
|
|
806
|
+
delete this.metalness;
|
|
807
|
+
delete this.roughness;
|
|
808
|
+
delete this.metalnessMap;
|
|
809
|
+
delete this.roughnessMap;
|
|
810
|
+
return this;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
class GLTFMaterialsPbrSpecularGlossinessExtension {
|
|
814
|
+
constructor() {
|
|
815
|
+
this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS;
|
|
816
|
+
this.specularGlossinessParams = [
|
|
817
|
+
'color',
|
|
818
|
+
'map',
|
|
819
|
+
'lightMap',
|
|
820
|
+
'lightMapIntensity',
|
|
821
|
+
'aoMap',
|
|
822
|
+
'aoMapIntensity',
|
|
823
|
+
'emissive',
|
|
824
|
+
'emissiveIntensity',
|
|
825
|
+
'emissiveMap',
|
|
826
|
+
'bumpMap',
|
|
827
|
+
'bumpScale',
|
|
828
|
+
'normalMap',
|
|
829
|
+
'normalMapType',
|
|
830
|
+
'displacementMap',
|
|
831
|
+
'displacementScale',
|
|
832
|
+
'displacementBias',
|
|
833
|
+
'specularMap',
|
|
834
|
+
'specular',
|
|
835
|
+
'glossinessMap',
|
|
836
|
+
'glossiness',
|
|
837
|
+
'alphaMap',
|
|
838
|
+
'envMap',
|
|
839
|
+
'envMapIntensity',
|
|
840
|
+
'refractionRatio',
|
|
841
|
+
];
|
|
842
|
+
}
|
|
843
|
+
getMaterialType() {
|
|
844
|
+
return GLTFMeshStandardSGMaterial;
|
|
845
|
+
}
|
|
846
|
+
extendParams(materialParams, materialDef, parser) {
|
|
847
|
+
const { THREE } = Externals.getInstance();
|
|
848
|
+
const pbrSpecularGlossiness = materialDef.extensions[this.name];
|
|
849
|
+
materialParams.color = new THREE.Color(1.0, 1.0, 1.0);
|
|
850
|
+
materialParams.opacity = 1.0;
|
|
851
|
+
const pending = [];
|
|
852
|
+
if (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {
|
|
853
|
+
const array = pbrSpecularGlossiness.diffuseFactor;
|
|
854
|
+
materialParams.color.fromArray(array);
|
|
855
|
+
materialParams.opacity = array[3];
|
|
856
|
+
}
|
|
857
|
+
if (pbrSpecularGlossiness.diffuseTexture !== undefined) {
|
|
858
|
+
pending.push(parser.assignTexture(materialParams, 'map', pbrSpecularGlossiness.diffuseTexture));
|
|
859
|
+
}
|
|
860
|
+
materialParams.emissive = new THREE.Color(0.0, 0.0, 0.0);
|
|
861
|
+
materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
|
|
862
|
+
materialParams.specular = new THREE.Color(1.0, 1.0, 1.0);
|
|
863
|
+
if (Array.isArray(pbrSpecularGlossiness.specularFactor)) {
|
|
864
|
+
materialParams.specular.fromArray(pbrSpecularGlossiness.specularFactor);
|
|
865
|
+
}
|
|
866
|
+
if (pbrSpecularGlossiness.specularGlossinessTexture !== undefined) {
|
|
867
|
+
const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
|
|
868
|
+
pending.push(parser.assignTexture(materialParams, 'glossinessMap', specGlossMapDef));
|
|
869
|
+
pending.push(parser.assignTexture(materialParams, 'specularMap', specGlossMapDef));
|
|
870
|
+
}
|
|
871
|
+
return Promise.all(pending);
|
|
872
|
+
}
|
|
873
|
+
createMaterial(materialParams) {
|
|
874
|
+
const { THREE } = Externals.getInstance();
|
|
875
|
+
const material = new GLTFMeshStandardSGMaterial(materialParams);
|
|
876
|
+
material.fog = true;
|
|
877
|
+
material.color = materialParams.color;
|
|
878
|
+
material.map = materialParams.map === undefined ? null : materialParams.map;
|
|
879
|
+
material.lightMap = null;
|
|
880
|
+
material.lightMapIntensity = 1.0;
|
|
881
|
+
material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
|
|
882
|
+
material.aoMapIntensity = 1.0;
|
|
883
|
+
material.emissive = materialParams.emissive;
|
|
884
|
+
material.emissiveIntensity = 1.0;
|
|
885
|
+
material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
|
|
886
|
+
material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
|
|
887
|
+
material.bumpScale = 1;
|
|
888
|
+
material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
|
|
889
|
+
material.normalMapType = THREE.TangentSpaceNormalMap;
|
|
890
|
+
if (materialParams.normalScale)
|
|
891
|
+
material.normalScale = materialParams.normalScale;
|
|
892
|
+
material.displacementMap = null;
|
|
893
|
+
material.displacementScale = 1;
|
|
894
|
+
material.displacementBias = 0;
|
|
895
|
+
material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
|
|
896
|
+
material.specular = materialParams.specular;
|
|
897
|
+
material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
|
|
898
|
+
material.glossiness = materialParams.glossiness;
|
|
899
|
+
material.alphaMap = null;
|
|
900
|
+
material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
|
|
901
|
+
material.envMapIntensity = 1.0;
|
|
902
|
+
material.refractionRatio = 0.98;
|
|
903
|
+
return material;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
class GLTFMeshQuantizationExtension {
|
|
907
|
+
constructor() {
|
|
908
|
+
this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
class GLTFCubicSplineInterpolant extends NS_THREE.Interpolant {
|
|
912
|
+
constructor() {
|
|
913
|
+
super(...arguments);
|
|
914
|
+
this.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
|
|
915
|
+
this.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
|
|
916
|
+
}
|
|
917
|
+
copySampleValue_(index) {
|
|
918
|
+
// Copies a sample value to the result buffer. See description of glTF
|
|
919
|
+
// CUBICSPLINE values layout in interpolate_() function below.
|
|
920
|
+
const result = this.resultBuffer;
|
|
921
|
+
const values = this.sampleValues;
|
|
922
|
+
const { valueSize } = this;
|
|
923
|
+
const offset = index * valueSize * 3 + valueSize;
|
|
924
|
+
for (let i = 0; i !== valueSize; i++) {
|
|
925
|
+
result[i] = values[offset + i];
|
|
926
|
+
}
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
interpolate_(i1, t0, t, t1) {
|
|
930
|
+
const result = this.resultBuffer;
|
|
931
|
+
const values = this.sampleValues;
|
|
932
|
+
const stride = this.valueSize;
|
|
933
|
+
const stride2 = stride * 2;
|
|
934
|
+
const stride3 = stride * 3;
|
|
935
|
+
const td = t1 - t0;
|
|
936
|
+
const p = (t - t0) / td;
|
|
937
|
+
const pp = p * p;
|
|
938
|
+
const ppp = pp * p;
|
|
939
|
+
const offset1 = i1 * stride3;
|
|
940
|
+
const offset0 = offset1 - stride3;
|
|
941
|
+
const s2 = -2 * ppp + 3 * pp;
|
|
942
|
+
const s3 = ppp - pp;
|
|
943
|
+
const s0 = 1 - s2;
|
|
944
|
+
const s1 = s3 - pp + p;
|
|
945
|
+
// Layout of keyframe output values for CUBICSPLINE animations:
|
|
946
|
+
// [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
|
|
947
|
+
for (let i = 0; i !== stride; i++) {
|
|
948
|
+
const p0 = values[offset0 + i + stride]; // splineVertex_k
|
|
949
|
+
const m0 = values[offset0 + i + stride2] * td; // outTangent_k * (t_k+1 - t_k)
|
|
950
|
+
const p1 = values[offset1 + i + stride]; // splineVertex_k+1
|
|
951
|
+
const m1 = values[offset1 + i] * td; // inTangent_k+1 * (t_k+1 - t_k)
|
|
952
|
+
result[i] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
|
|
953
|
+
}
|
|
954
|
+
return result;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* @param {BufferGeometry} geometry
|
|
959
|
+
* @param {GLTF.Primitive} primitiveDef
|
|
960
|
+
* @param {GLTFParser} parser
|
|
961
|
+
*/
|
|
962
|
+
function computeBounds(geometry, primitiveDef, parser) {
|
|
963
|
+
const { attributes } = primitiveDef;
|
|
964
|
+
const { THREE } = Externals.getInstance();
|
|
965
|
+
const box = new THREE.Box3();
|
|
966
|
+
if (attributes.POSITION !== undefined) {
|
|
967
|
+
const accessor = parser.json.accessors[attributes.POSITION];
|
|
968
|
+
const { min } = accessor;
|
|
969
|
+
const { max } = accessor;
|
|
970
|
+
// glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
|
|
971
|
+
if (min !== undefined && max !== undefined) {
|
|
972
|
+
box.set(new THREE.Vector3(min[0], min[1], min[2]), new THREE.Vector3(max[0], max[1], max[2]));
|
|
973
|
+
}
|
|
974
|
+
else {
|
|
975
|
+
console.warn('THREE.GLTFLoader: Missing min/max properties for accessor POSITION.');
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
const { targets } = primitiveDef;
|
|
983
|
+
if (targets !== undefined) {
|
|
984
|
+
const maxDisplacement = new THREE.Vector3();
|
|
985
|
+
const vector = new THREE.Vector3();
|
|
986
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
987
|
+
const target = targets[i];
|
|
988
|
+
if (target.POSITION !== undefined) {
|
|
989
|
+
const accessor = parser.json.accessors[target.POSITION];
|
|
990
|
+
const { min } = accessor;
|
|
991
|
+
const { max } = accessor;
|
|
992
|
+
// glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
|
|
993
|
+
if (min !== undefined && max !== undefined) {
|
|
994
|
+
// we need to get max of absolute components because target weight is [-1,1]
|
|
995
|
+
vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));
|
|
996
|
+
vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));
|
|
997
|
+
vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));
|
|
998
|
+
// Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
|
|
999
|
+
// to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
|
|
1000
|
+
// are used to implement key-frame animations and as such only two are active at a time - this results in very large
|
|
1001
|
+
// boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
|
|
1002
|
+
maxDisplacement.max(vector);
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
console.warn('THREE.GLTFLoader: Missing min/max properties for accessor POSITION.');
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
// As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
|
|
1010
|
+
box.expandByVector(maxDisplacement);
|
|
1011
|
+
}
|
|
1012
|
+
geometry.boundingBox = box;
|
|
1013
|
+
const sphere = new THREE.Sphere();
|
|
1014
|
+
box.getCenter(sphere.center);
|
|
1015
|
+
sphere.radius = box.min.distanceTo(box.max) / 2;
|
|
1016
|
+
geometry.boundingSphere = sphere;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* @param {BufferGeometry} geometry
|
|
1020
|
+
* @param {GLTF.Primitive} primitiveDef
|
|
1021
|
+
* @param {GLTFParser} parser
|
|
1022
|
+
* @return {Promise<BufferGeometry>}
|
|
1023
|
+
*/
|
|
1024
|
+
function addPrimitiveAttributes(geometry, primitiveDef, parser) {
|
|
1025
|
+
const { attributes } = primitiveDef;
|
|
1026
|
+
const pending = [];
|
|
1027
|
+
function assignAttributeAccessor(accessorIndex, attributeName) {
|
|
1028
|
+
return parser.getDependency('accessor', accessorIndex)
|
|
1029
|
+
.then((accessor) => {
|
|
1030
|
+
geometry.setAttribute(attributeName, accessor);
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
for (const gltfAttributeName in attributes) {
|
|
1034
|
+
const threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();
|
|
1035
|
+
// Skip attributes already provided by e.g. Draco extension.
|
|
1036
|
+
if (threeAttributeName in geometry.attributes)
|
|
1037
|
+
continue;
|
|
1038
|
+
pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));
|
|
1039
|
+
}
|
|
1040
|
+
if (primitiveDef.indices !== undefined && !geometry.index) {
|
|
1041
|
+
const accessor = parser.getDependency('accessor', primitiveDef.indices).then((accessor) => {
|
|
1042
|
+
geometry.setIndex(accessor);
|
|
1043
|
+
});
|
|
1044
|
+
pending.push(accessor);
|
|
1045
|
+
}
|
|
1046
|
+
assignExtrasToUserData(geometry, primitiveDef);
|
|
1047
|
+
computeBounds(geometry, primitiveDef, parser);
|
|
1048
|
+
return Promise.all(pending).then(() => (primitiveDef.targets !== undefined
|
|
1049
|
+
? addMorphTargets(geometry, primitiveDef.targets, parser)
|
|
1050
|
+
: geometry));
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* @param {BufferGeometry} geometry
|
|
1054
|
+
* @param {Number} drawMode
|
|
1055
|
+
* @return {BufferGeometry}
|
|
1056
|
+
*/
|
|
1057
|
+
function toTrianglesDrawMode(geometry, drawMode) {
|
|
1058
|
+
let index = geometry.getIndex();
|
|
1059
|
+
// generate index if not present
|
|
1060
|
+
if (index === null) {
|
|
1061
|
+
const indices = [];
|
|
1062
|
+
const position = geometry.getAttribute('position');
|
|
1063
|
+
if (position !== undefined) {
|
|
1064
|
+
for (let i = 0; i < position.count; i++) {
|
|
1065
|
+
indices.push(i);
|
|
1066
|
+
}
|
|
1067
|
+
geometry.setIndex(indices);
|
|
1068
|
+
index = geometry.getIndex();
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
console.error('THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.');
|
|
1072
|
+
return geometry;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
//
|
|
1076
|
+
const numberOfTriangles = index.count - 2;
|
|
1077
|
+
const newIndices = [];
|
|
1078
|
+
const { THREE } = Externals.getInstance();
|
|
1079
|
+
if (drawMode === THREE.TriangleFanDrawMode) {
|
|
1080
|
+
// gl.TRIANGLE_FAN
|
|
1081
|
+
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
1082
|
+
newIndices.push(index.getX(0));
|
|
1083
|
+
newIndices.push(index.getX(i));
|
|
1084
|
+
newIndices.push(index.getX(i + 1));
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
// gl.TRIANGLE_STRIP
|
|
1089
|
+
for (let i = 0; i < numberOfTriangles; i++) {
|
|
1090
|
+
if (i % 2 === 0) {
|
|
1091
|
+
newIndices.push(index.getX(i));
|
|
1092
|
+
newIndices.push(index.getX(i + 1));
|
|
1093
|
+
newIndices.push(index.getX(i + 2));
|
|
1094
|
+
}
|
|
1095
|
+
else {
|
|
1096
|
+
newIndices.push(index.getX(i + 2));
|
|
1097
|
+
newIndices.push(index.getX(i + 1));
|
|
1098
|
+
newIndices.push(index.getX(i));
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if ((newIndices.length / 3) !== numberOfTriangles) {
|
|
1103
|
+
console.error('THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.');
|
|
1104
|
+
}
|
|
1105
|
+
// build final geometry
|
|
1106
|
+
const newGeometry = geometry.clone();
|
|
1107
|
+
newGeometry.setIndex(newIndices);
|
|
1108
|
+
return newGeometry;
|
|
1109
|
+
}
|
|
1110
|
+
class GLTFParser {
|
|
1111
|
+
constructor(json, options) {
|
|
1112
|
+
this.loadScene = ((() => {
|
|
1113
|
+
// scene node hierachy builder
|
|
1114
|
+
function buildNodeHierachy(nodeId, parentObject, json, parser) {
|
|
1115
|
+
const { THREE } = Externals.getInstance();
|
|
1116
|
+
const nodeDef = json.nodes[nodeId];
|
|
1117
|
+
return parser.getDependency('node', nodeId).then((node) => {
|
|
1118
|
+
if (nodeDef.skin === undefined)
|
|
1119
|
+
return node;
|
|
1120
|
+
// build skeleton here as well
|
|
1121
|
+
let skinEntry;
|
|
1122
|
+
return parser.getDependency('skin', nodeDef.skin).then((skin) => {
|
|
1123
|
+
skinEntry = skin;
|
|
1124
|
+
const pendingJoints = [];
|
|
1125
|
+
for (let i = 0, il = skinEntry.joints.length; i < il; i++) {
|
|
1126
|
+
pendingJoints.push(parser.getDependency('node', skinEntry.joints[i]));
|
|
1127
|
+
}
|
|
1128
|
+
return Promise.all(pendingJoints);
|
|
1129
|
+
}).then((jointNodes) => {
|
|
1130
|
+
node.traverse((mesh) => {
|
|
1131
|
+
if (!mesh.isMesh)
|
|
1132
|
+
return;
|
|
1133
|
+
const bones = [];
|
|
1134
|
+
const boneInverses = [];
|
|
1135
|
+
for (let j = 0, jl = jointNodes.length; j < jl; j++) {
|
|
1136
|
+
const jointNode = jointNodes[j];
|
|
1137
|
+
if (jointNode) {
|
|
1138
|
+
bones.push(jointNode);
|
|
1139
|
+
const mat = new THREE.Matrix4();
|
|
1140
|
+
if (skinEntry.inverseBindMatrices !== undefined) {
|
|
1141
|
+
mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);
|
|
1142
|
+
}
|
|
1143
|
+
boneInverses.push(mat);
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[j]);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
mesh.bind(new THREE.Skeleton(bones, boneInverses), mesh.matrixWorld);
|
|
1150
|
+
});
|
|
1151
|
+
return node;
|
|
1152
|
+
});
|
|
1153
|
+
}).then((node) => {
|
|
1154
|
+
// build node hierachy
|
|
1155
|
+
parentObject.add(node);
|
|
1156
|
+
const pending = [];
|
|
1157
|
+
if (nodeDef.children) {
|
|
1158
|
+
const children = nodeDef.children;
|
|
1159
|
+
for (let i = 0, il = children.length; i < il; i++) {
|
|
1160
|
+
const child = children[i];
|
|
1161
|
+
pending.push(buildNodeHierachy(child, node, json, parser));
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
return Promise.all(pending);
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
const that = this;
|
|
1168
|
+
return function loadScene(sceneIndex) {
|
|
1169
|
+
const json = that.json;
|
|
1170
|
+
const extensions = that.extensions;
|
|
1171
|
+
const sceneDef = that.json.scenes[sceneIndex];
|
|
1172
|
+
const parser = that;
|
|
1173
|
+
const { THREE } = Externals.getInstance();
|
|
1174
|
+
// Loader returns Group, not Scene.
|
|
1175
|
+
// See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
|
|
1176
|
+
const scene = new THREE.Group();
|
|
1177
|
+
if (sceneDef.name)
|
|
1178
|
+
scene.name = parser.createUniqueName(sceneDef.name);
|
|
1179
|
+
assignExtrasToUserData(scene, sceneDef);
|
|
1180
|
+
if (sceneDef.extensions)
|
|
1181
|
+
addUnknownExtensionsToUserData(extensions, scene, sceneDef);
|
|
1182
|
+
const nodeIds = sceneDef.nodes || [];
|
|
1183
|
+
const pending = [];
|
|
1184
|
+
for (let i = 0, il = nodeIds.length; i < il; i++) {
|
|
1185
|
+
pending.push(buildNodeHierachy(nodeIds[i], scene, json, parser));
|
|
1186
|
+
}
|
|
1187
|
+
return Promise.all(pending).then(() => scene);
|
|
1188
|
+
};
|
|
1189
|
+
})());
|
|
1190
|
+
this.json = json || {};
|
|
1191
|
+
this.extensions = {};
|
|
1192
|
+
this.plugins = {};
|
|
1193
|
+
this.options = options || {};
|
|
1194
|
+
// loader object cache
|
|
1195
|
+
this.cache = new GLTFRegistry();
|
|
1196
|
+
// associations between Three.js objects and glTF elements
|
|
1197
|
+
this.associations = new Map();
|
|
1198
|
+
// BufferGeometry caching
|
|
1199
|
+
this.primitiveCache = {};
|
|
1200
|
+
// Object3D instance caches
|
|
1201
|
+
this.meshCache = { refs: {}, uses: {} };
|
|
1202
|
+
this.cameraCache = { refs: {}, uses: {} };
|
|
1203
|
+
this.lightCache = { refs: {}, uses: {} };
|
|
1204
|
+
// Track node names, to ensure no duplicates
|
|
1205
|
+
this.nodeNamesUsed = {};
|
|
1206
|
+
const { THREE } = Externals.getInstance();
|
|
1207
|
+
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
1208
|
+
// expensive work of uploading a texture to the GPU off the main thread.
|
|
1209
|
+
if (typeof createImageBitmap !== 'undefined' && /Firefox/.test(navigator.userAgent) === false) {
|
|
1210
|
+
this.textureLoader = new THREE.ImageBitmapLoader(this.options.manager);
|
|
1211
|
+
}
|
|
1212
|
+
else {
|
|
1213
|
+
this.textureLoader = new THREE.TextureLoader(this.options.manager);
|
|
1214
|
+
}
|
|
1215
|
+
this.textureLoader.setCrossOrigin(this.options.crossOrigin);
|
|
1216
|
+
this.textureLoader.setRequestHeader(this.options.requestHeader);
|
|
1217
|
+
this.fileLoader = new THREE.FileLoader(this.options.manager);
|
|
1218
|
+
this.fileLoader.setResponseType('arraybuffer');
|
|
1219
|
+
if (this.options.crossOrigin === 'use-credentials') {
|
|
1220
|
+
this.fileLoader.setWithCredentials(true);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
setExtensions(extensions) {
|
|
1224
|
+
this.extensions = extensions;
|
|
1225
|
+
}
|
|
1226
|
+
setPlugins(plugins) {
|
|
1227
|
+
this.plugins = plugins;
|
|
1228
|
+
}
|
|
1229
|
+
parse(onLoad, onError) {
|
|
1230
|
+
const parser = this;
|
|
1231
|
+
const json = this.json;
|
|
1232
|
+
const extensions = this.extensions;
|
|
1233
|
+
// Clear the loader cache
|
|
1234
|
+
this.cache.removeAll();
|
|
1235
|
+
// Mark the special nodes/meshes in json for efficient parse
|
|
1236
|
+
this._invokeAll((ext) => ext._markDefs && ext._markDefs());
|
|
1237
|
+
Promise.all(this._invokeAll((ext) => ext.beforeRoot && ext.beforeRoot())).then(() => Promise.all([
|
|
1238
|
+
parser.getDependencies('scene'),
|
|
1239
|
+
parser.getDependencies('animation'),
|
|
1240
|
+
parser.getDependencies('camera'),
|
|
1241
|
+
])).then((dependencies) => {
|
|
1242
|
+
const result = {
|
|
1243
|
+
scene: dependencies[0][json.scene || 0],
|
|
1244
|
+
scenes: dependencies[0],
|
|
1245
|
+
animations: dependencies[1],
|
|
1246
|
+
cameras: dependencies[2],
|
|
1247
|
+
asset: json.asset,
|
|
1248
|
+
parser,
|
|
1249
|
+
userData: {},
|
|
1250
|
+
};
|
|
1251
|
+
addUnknownExtensionsToUserData(extensions, result, json);
|
|
1252
|
+
assignExtrasToUserData(result, json);
|
|
1253
|
+
Promise.all(parser._invokeAll((ext) => ext.afterRoot && ext.afterRoot(result))).then(() => {
|
|
1254
|
+
onLoad(result);
|
|
1255
|
+
});
|
|
1256
|
+
}).catch(onError);
|
|
1257
|
+
}
|
|
1258
|
+
_markDefs() {
|
|
1259
|
+
const nodeDefs = this.json.nodes || [];
|
|
1260
|
+
const skinDefs = this.json.skins || [];
|
|
1261
|
+
const meshDefs = this.json.meshes || [];
|
|
1262
|
+
// Nothing in the node definition indicates whether it is a Bone or an
|
|
1263
|
+
// Object3D. Use the skins' joint references to mark bones.
|
|
1264
|
+
for (let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {
|
|
1265
|
+
const joints = skinDefs[skinIndex].joints;
|
|
1266
|
+
for (let i = 0, il = joints.length; i < il; i++) {
|
|
1267
|
+
nodeDefs[joints[i]].isBone = true;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
// Iterate over all nodes, marking references to shared resources,
|
|
1271
|
+
// as well as skeleton joints.
|
|
1272
|
+
for (let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
|
|
1273
|
+
const nodeDef = nodeDefs[nodeIndex];
|
|
1274
|
+
if (nodeDef.mesh !== undefined) {
|
|
1275
|
+
this._addNodeRef(this.meshCache, nodeDef.mesh);
|
|
1276
|
+
// Nothing in the mesh definition indicates whether it is
|
|
1277
|
+
// a SkinnedMesh or Mesh. Use the node's mesh reference
|
|
1278
|
+
// to mark SkinnedMesh if node has skin.
|
|
1279
|
+
if (nodeDef.skin !== undefined) {
|
|
1280
|
+
meshDefs[nodeDef.mesh].isSkinnedMesh = true;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if (nodeDef.camera !== undefined) {
|
|
1284
|
+
this._addNodeRef(this.cameraCache, nodeDef.camera);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
_addNodeRef(cache, index) {
|
|
1289
|
+
if (index === undefined)
|
|
1290
|
+
return;
|
|
1291
|
+
if (cache.refs[index] === undefined) {
|
|
1292
|
+
cache.refs[index] = cache.uses[index] = 0;
|
|
1293
|
+
}
|
|
1294
|
+
cache.refs[index]++;
|
|
1295
|
+
}
|
|
1296
|
+
_getNodeRef(cache, index, object) {
|
|
1297
|
+
if (cache.refs[index] <= 1)
|
|
1298
|
+
return object;
|
|
1299
|
+
const ref = object.clone();
|
|
1300
|
+
ref.name += `_instance_${cache.uses[index]++}`;
|
|
1301
|
+
return ref;
|
|
1302
|
+
}
|
|
1303
|
+
_invokeOne(func) {
|
|
1304
|
+
const extensions = Object.values(this.plugins);
|
|
1305
|
+
extensions.push(this);
|
|
1306
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1307
|
+
const result = func(extensions[i]);
|
|
1308
|
+
if (result)
|
|
1309
|
+
return result;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
_invokeAll(func) {
|
|
1313
|
+
const extensions = Object.values(this.plugins);
|
|
1314
|
+
extensions.unshift(this);
|
|
1315
|
+
const pending = [];
|
|
1316
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1317
|
+
const result = func(extensions[i]);
|
|
1318
|
+
if (result)
|
|
1319
|
+
pending.push(result);
|
|
1320
|
+
}
|
|
1321
|
+
return pending;
|
|
1322
|
+
}
|
|
1323
|
+
getDependency(type, index) {
|
|
1324
|
+
const cacheKey = `${type}:${index}`;
|
|
1325
|
+
let dependency = this.cache.get(cacheKey);
|
|
1326
|
+
if (!dependency) {
|
|
1327
|
+
switch (type) {
|
|
1328
|
+
case 'scene':
|
|
1329
|
+
dependency = this.loadScene(index);
|
|
1330
|
+
break;
|
|
1331
|
+
case 'node':
|
|
1332
|
+
dependency = this.loadNode(index);
|
|
1333
|
+
break;
|
|
1334
|
+
case 'mesh':
|
|
1335
|
+
dependency = this._invokeOne((ext) => ext.loadMesh && ext.loadMesh(index));
|
|
1336
|
+
break;
|
|
1337
|
+
case 'accessor':
|
|
1338
|
+
dependency = this.loadAccessor(index);
|
|
1339
|
+
break;
|
|
1340
|
+
case 'bufferView':
|
|
1341
|
+
dependency = this._invokeOne((ext) => ext.loadBufferView && ext.loadBufferView(index));
|
|
1342
|
+
break;
|
|
1343
|
+
case 'buffer':
|
|
1344
|
+
dependency = this.loadBuffer(index);
|
|
1345
|
+
break;
|
|
1346
|
+
case 'material':
|
|
1347
|
+
dependency = this._invokeOne((ext) => ext.loadMaterial && ext.loadMaterial(index));
|
|
1348
|
+
break;
|
|
1349
|
+
case 'texture':
|
|
1350
|
+
dependency = this._invokeOne((ext) => ext.loadTexture && ext.loadTexture(index));
|
|
1351
|
+
break;
|
|
1352
|
+
case 'skin':
|
|
1353
|
+
dependency = this.loadSkin(index);
|
|
1354
|
+
break;
|
|
1355
|
+
case 'animation':
|
|
1356
|
+
dependency = this.loadAnimation(index);
|
|
1357
|
+
break;
|
|
1358
|
+
case 'camera':
|
|
1359
|
+
dependency = this.loadCamera(index);
|
|
1360
|
+
break;
|
|
1361
|
+
default:
|
|
1362
|
+
throw new Error(`Unknown type: ${type}`);
|
|
1363
|
+
}
|
|
1364
|
+
this.cache.add(cacheKey, dependency);
|
|
1365
|
+
}
|
|
1366
|
+
return dependency;
|
|
1367
|
+
}
|
|
1368
|
+
getDependencies(type) {
|
|
1369
|
+
let dependencies = this.cache.get(type);
|
|
1370
|
+
if (!dependencies) {
|
|
1371
|
+
const parser = this;
|
|
1372
|
+
const defs = this.json[type + (type === 'mesh' ? 'es' : 's')] || [];
|
|
1373
|
+
dependencies = Promise.all(defs.map((def, index) => parser.getDependency(type, index)));
|
|
1374
|
+
this.cache.add(type, dependencies);
|
|
1375
|
+
}
|
|
1376
|
+
return dependencies;
|
|
1377
|
+
}
|
|
1378
|
+
loadBuffer(bufferIndex) {
|
|
1379
|
+
const bufferDef = this.json.buffers[bufferIndex];
|
|
1380
|
+
const loader = this.fileLoader;
|
|
1381
|
+
if (bufferDef.type && bufferDef.type !== 'arraybuffer') {
|
|
1382
|
+
throw new Error(`THREE.GLTFLoader: ${bufferDef.type} buffer type is not supported.`);
|
|
1383
|
+
}
|
|
1384
|
+
// If present, GLB container is required to be the first buffer.
|
|
1385
|
+
if (bufferDef.uri === undefined && bufferIndex === 0) {
|
|
1386
|
+
return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);
|
|
1387
|
+
}
|
|
1388
|
+
const options = this.options;
|
|
1389
|
+
return new Promise(((resolve, reject) => {
|
|
1390
|
+
loader.load(resolveURL(bufferDef.uri, options.path), resolve, undefined, () => {
|
|
1391
|
+
reject(new Error(`THREE.GLTFLoader: Failed to load buffer "${bufferDef.uri}".`));
|
|
1392
|
+
});
|
|
1393
|
+
}));
|
|
1394
|
+
}
|
|
1395
|
+
loadBufferView(bufferViewIndex) {
|
|
1396
|
+
const bufferViewDef = this.json.bufferViews[bufferViewIndex];
|
|
1397
|
+
return this.getDependency('buffer', bufferViewDef.buffer).then((buffer) => {
|
|
1398
|
+
const byteLength = bufferViewDef.byteLength || 0;
|
|
1399
|
+
const byteOffset = bufferViewDef.byteOffset || 0;
|
|
1400
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
loadAccessor(accessorIndex) {
|
|
1404
|
+
const parser = this;
|
|
1405
|
+
const json = this.json;
|
|
1406
|
+
const accessorDef = this.json.accessors[accessorIndex];
|
|
1407
|
+
const { THREE } = Externals.getInstance();
|
|
1408
|
+
if (accessorDef.bufferView === undefined && accessorDef.sparse === undefined) {
|
|
1409
|
+
// Ignore empty accessors, which may be used to declare runtime
|
|
1410
|
+
// information about attributes coming from another source (e.g. Draco
|
|
1411
|
+
// compression extension).
|
|
1412
|
+
return Promise.resolve(null);
|
|
1413
|
+
}
|
|
1414
|
+
const pendingBufferViews = [];
|
|
1415
|
+
if (accessorDef.bufferView !== undefined) {
|
|
1416
|
+
pendingBufferViews.push(this.getDependency('bufferView', accessorDef.bufferView));
|
|
1417
|
+
}
|
|
1418
|
+
else {
|
|
1419
|
+
pendingBufferViews.push(null);
|
|
1420
|
+
}
|
|
1421
|
+
if (accessorDef.sparse !== undefined) {
|
|
1422
|
+
pendingBufferViews.push(this.getDependency('bufferView', accessorDef.sparse.indices.bufferView));
|
|
1423
|
+
pendingBufferViews.push(this.getDependency('bufferView', accessorDef.sparse.values.bufferView));
|
|
1424
|
+
}
|
|
1425
|
+
return Promise.all(pendingBufferViews).then((bufferViews) => {
|
|
1426
|
+
const bufferView = bufferViews[0];
|
|
1427
|
+
const itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
|
|
1428
|
+
const TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
1429
|
+
// For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
|
|
1430
|
+
const elementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
1431
|
+
const itemBytes = elementBytes * itemSize;
|
|
1432
|
+
const byteOffset = accessorDef.byteOffset || 0;
|
|
1433
|
+
const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[accessorDef.bufferView].byteStride : undefined;
|
|
1434
|
+
const normalized = accessorDef.normalized === true;
|
|
1435
|
+
let array;
|
|
1436
|
+
let bufferAttribute;
|
|
1437
|
+
// The buffer is not interleaved if the stride is the item size in bytes.
|
|
1438
|
+
if (byteStride && byteStride !== itemBytes) {
|
|
1439
|
+
// Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer
|
|
1440
|
+
// This makes sure that IBA.count reflects accessor.count properly
|
|
1441
|
+
const ibSlice = Math.floor(byteOffset / byteStride);
|
|
1442
|
+
const ibCacheKey = `InterleavedBuffer:${accessorDef.bufferView}:${accessorDef.componentType}:${ibSlice}:${accessorDef.count}`;
|
|
1443
|
+
let ib = parser.cache.get(ibCacheKey);
|
|
1444
|
+
if (!ib) {
|
|
1445
|
+
array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
|
|
1446
|
+
// Integer parameters to IB/IBA are in array elements, not bytes.
|
|
1447
|
+
ib = new THREE.InterleavedBuffer(array, byteStride / elementBytes);
|
|
1448
|
+
parser.cache.add(ibCacheKey, ib);
|
|
1449
|
+
}
|
|
1450
|
+
bufferAttribute = new THREE.InterleavedBufferAttribute(ib, itemSize, (byteOffset % byteStride) / elementBytes, normalized);
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
if (bufferView === null) {
|
|
1454
|
+
array = new TypedArray(accessorDef.count * itemSize);
|
|
1455
|
+
}
|
|
1456
|
+
else {
|
|
1457
|
+
array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
|
|
1458
|
+
}
|
|
1459
|
+
bufferAttribute = new THREE.BufferAttribute(array, itemSize, normalized);
|
|
1460
|
+
}
|
|
1461
|
+
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
|
|
1462
|
+
if (accessorDef.sparse !== undefined) {
|
|
1463
|
+
const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
|
|
1464
|
+
const TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];
|
|
1465
|
+
const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
|
|
1466
|
+
const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
|
|
1467
|
+
const sparseIndices = new TypedArrayIndices(bufferViews[1], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices);
|
|
1468
|
+
const sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
|
|
1469
|
+
if (bufferView !== null) {
|
|
1470
|
+
// Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
|
|
1471
|
+
bufferAttribute = new THREE.BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
|
|
1472
|
+
}
|
|
1473
|
+
for (let i = 0, il = sparseIndices.length; i < il; i++) {
|
|
1474
|
+
const index = sparseIndices[i];
|
|
1475
|
+
bufferAttribute.setX(index, sparseValues[i * itemSize]);
|
|
1476
|
+
if (itemSize >= 2)
|
|
1477
|
+
bufferAttribute.setY(index, sparseValues[i * itemSize + 1]);
|
|
1478
|
+
if (itemSize >= 3)
|
|
1479
|
+
bufferAttribute.setZ(index, sparseValues[i * itemSize + 2]);
|
|
1480
|
+
if (itemSize >= 4)
|
|
1481
|
+
bufferAttribute.setW(index, sparseValues[i * itemSize + 3]);
|
|
1482
|
+
if (itemSize >= 5)
|
|
1483
|
+
throw new Error('THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.');
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
return bufferAttribute;
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
loadTexture(textureIndex) {
|
|
1490
|
+
const json = this.json;
|
|
1491
|
+
const options = this.options;
|
|
1492
|
+
const textureDef = json.textures[textureIndex];
|
|
1493
|
+
const source = json.images[textureDef.source];
|
|
1494
|
+
let loader = this.textureLoader;
|
|
1495
|
+
if (source.uri) {
|
|
1496
|
+
const handler = options.manager.getHandler(source.uri);
|
|
1497
|
+
if (handler !== null)
|
|
1498
|
+
loader = handler;
|
|
1499
|
+
}
|
|
1500
|
+
return this.loadTextureImage(textureIndex, source, loader);
|
|
1501
|
+
}
|
|
1502
|
+
loadTextureImage(textureIndex, source, loader) {
|
|
1503
|
+
const parser = this;
|
|
1504
|
+
const json = this.json;
|
|
1505
|
+
const options = this.options;
|
|
1506
|
+
const textureDef = json.textures[textureIndex];
|
|
1507
|
+
let URL = {};
|
|
1508
|
+
if (EnvironmentUtils.GetEnv() === Env.Miniapp) {
|
|
1509
|
+
URL = {};
|
|
1510
|
+
}
|
|
1511
|
+
else {
|
|
1512
|
+
URL = self ? self.URL || self.webkitURL : {};
|
|
1513
|
+
}
|
|
1514
|
+
const { THREE } = Externals.getInstance();
|
|
1515
|
+
let sourceURI = source.uri;
|
|
1516
|
+
let isObjectURL = false;
|
|
1517
|
+
let hasAlpha = true;
|
|
1518
|
+
if (source.mimeType === 'image/jpeg')
|
|
1519
|
+
hasAlpha = false;
|
|
1520
|
+
if (source.bufferView !== undefined) {
|
|
1521
|
+
// Load binary image data from bufferView, if provided.
|
|
1522
|
+
sourceURI = parser.getDependency('bufferView', source.bufferView).then((bufferView) => {
|
|
1523
|
+
if (source.mimeType === 'image/png') {
|
|
1524
|
+
// Inspect the PNG 'IHDR' chunk to determine whether the image could have an
|
|
1525
|
+
// alpha channel. This check is conservative — the image could have an alpha
|
|
1526
|
+
// channel with all values == 1, and the indexed type (colorType == 3) only
|
|
1527
|
+
// sometimes contains alpha.
|
|
1528
|
+
//
|
|
1529
|
+
// https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header
|
|
1530
|
+
const colorType = new DataView(bufferView, 25, 1).getUint8(0);
|
|
1531
|
+
hasAlpha = colorType === 6 || colorType === 4 || colorType === 3;
|
|
1532
|
+
}
|
|
1533
|
+
isObjectURL = true;
|
|
1534
|
+
try {
|
|
1535
|
+
if (EnvironmentUtils.GetEnv() === Env.Miniapp) {
|
|
1536
|
+
sourceURI = wx.arrayBufferToBase64(bufferView);
|
|
1537
|
+
return `data:image/png;base64,${sourceURI}`;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
catch (_a) {
|
|
1541
|
+
// do nothing
|
|
1542
|
+
}
|
|
1543
|
+
const blob = new Blob([bufferView], { type: source.mimeType });
|
|
1544
|
+
sourceURI = URL.createObjectURL(blob);
|
|
1545
|
+
return sourceURI;
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
else if (source.uri === undefined) {
|
|
1549
|
+
throw new Error(`THREE.GLTFLoader: Image ${textureIndex} is missing URI and bufferView`);
|
|
1550
|
+
}
|
|
1551
|
+
return Promise.resolve(sourceURI).then((sourceURI) => new Promise(((resolve, reject) => {
|
|
1552
|
+
let onLoad = resolve;
|
|
1553
|
+
if (loader.isImageBitmapLoader === true) {
|
|
1554
|
+
onLoad = function (imageBitmap) {
|
|
1555
|
+
resolve(new THREE.CanvasTexture(imageBitmap));
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
loader.load(resolveURL(sourceURI, options.path), onLoad, undefined, reject);
|
|
1559
|
+
}))).then((texture) => {
|
|
1560
|
+
// Clean up resources and configure Texture.
|
|
1561
|
+
try {
|
|
1562
|
+
if (EnvironmentUtils.GetEnv() === Env.Miniapp) {
|
|
1563
|
+
// do nothing
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
catch (_a) {
|
|
1567
|
+
if (isObjectURL === true) {
|
|
1568
|
+
URL.revokeObjectURL(sourceURI);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
texture.flipY = false;
|
|
1572
|
+
if (textureDef.name)
|
|
1573
|
+
texture.name = textureDef.name;
|
|
1574
|
+
// When there is definitely no alpha channel in the texture, set RGBFormat to save space.
|
|
1575
|
+
if (!hasAlpha)
|
|
1576
|
+
texture.format = THREE.RGBFormat;
|
|
1577
|
+
const samplers = json.samplers || {};
|
|
1578
|
+
const sampler = samplers[textureDef.sampler] || {};
|
|
1579
|
+
texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || THREE.LinearFilter;
|
|
1580
|
+
texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || THREE.LinearMipmapLinearFilter;
|
|
1581
|
+
texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || THREE.RepeatWrapping;
|
|
1582
|
+
texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || THREE.RepeatWrapping;
|
|
1583
|
+
parser.associations.set(texture, {
|
|
1584
|
+
type: 'textures',
|
|
1585
|
+
index: textureIndex,
|
|
1586
|
+
});
|
|
1587
|
+
return texture;
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
assignTexture(materialParams, mapName, mapDef) {
|
|
1591
|
+
const parser = this;
|
|
1592
|
+
return this.getDependency('texture', mapDef.index).then((texture) => {
|
|
1593
|
+
// Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
|
|
1594
|
+
// However, we will copy UV set 0 to UV set 1 on demand for aoMap
|
|
1595
|
+
if (mapDef.texCoord !== undefined && mapDef.texCoord !== 0 && !(mapName === 'aoMap' && mapDef.texCoord === 1)) {
|
|
1596
|
+
console.warn(`THREE.GLTFLoader: Custom UV set ${mapDef.texCoord} for texture ${mapName} not yet supported.`);
|
|
1597
|
+
}
|
|
1598
|
+
if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {
|
|
1599
|
+
const transform = mapDef.extensions !== undefined ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM] : undefined;
|
|
1600
|
+
if (transform) {
|
|
1601
|
+
const gltfReference = parser.associations.get(texture);
|
|
1602
|
+
texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture, transform);
|
|
1603
|
+
parser.associations.set(texture, gltfReference);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
materialParams[mapName] = texture;
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
assignFinalMaterial(mesh) {
|
|
1610
|
+
const geometry = mesh.geometry;
|
|
1611
|
+
let material = mesh.material;
|
|
1612
|
+
const useVertexTangents = geometry.attributes.tangent !== undefined;
|
|
1613
|
+
const useVertexColors = geometry.attributes.color !== undefined;
|
|
1614
|
+
const useFlatShading = geometry.attributes.normal === undefined;
|
|
1615
|
+
const useSkinning = mesh.isSkinnedMesh === true;
|
|
1616
|
+
const useMorphTargets = Object.keys(geometry.morphAttributes).length > 0;
|
|
1617
|
+
const useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== undefined;
|
|
1618
|
+
const { THREE } = Externals.getInstance();
|
|
1619
|
+
if (mesh.isPoints) {
|
|
1620
|
+
const cacheKey = `PointsMaterial:${material.uuid}`;
|
|
1621
|
+
let pointsMaterial = this.cache.get(cacheKey);
|
|
1622
|
+
if (!pointsMaterial) {
|
|
1623
|
+
pointsMaterial = new THREE.PointsMaterial();
|
|
1624
|
+
THREE.Material.prototype.copy.call(pointsMaterial, material);
|
|
1625
|
+
pointsMaterial.color.copy(material.color);
|
|
1626
|
+
pointsMaterial.map = material.map;
|
|
1627
|
+
pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
|
|
1628
|
+
this.cache.add(cacheKey, pointsMaterial);
|
|
1629
|
+
}
|
|
1630
|
+
material = pointsMaterial;
|
|
1631
|
+
}
|
|
1632
|
+
else if (mesh.isLine) {
|
|
1633
|
+
const cacheKey = `LineBasicMaterial:${material.uuid}`;
|
|
1634
|
+
let lineMaterial = this.cache.get(cacheKey);
|
|
1635
|
+
if (!lineMaterial) {
|
|
1636
|
+
lineMaterial = new THREE.LineBasicMaterial();
|
|
1637
|
+
THREE.Material.prototype.copy.call(lineMaterial, material);
|
|
1638
|
+
lineMaterial.color.copy(material.color);
|
|
1639
|
+
this.cache.add(cacheKey, lineMaterial);
|
|
1640
|
+
}
|
|
1641
|
+
material = lineMaterial;
|
|
1642
|
+
}
|
|
1643
|
+
// Clone the material if it will be modified
|
|
1644
|
+
if (useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets) {
|
|
1645
|
+
let cacheKey = `ClonedMaterial:${material.uuid}:`;
|
|
1646
|
+
if (material.isGLTFSpecularGlossinessMaterial)
|
|
1647
|
+
cacheKey += 'specular-glossiness:';
|
|
1648
|
+
if (useSkinning)
|
|
1649
|
+
cacheKey += 'skinning:';
|
|
1650
|
+
if (useVertexTangents)
|
|
1651
|
+
cacheKey += 'vertex-tangents:';
|
|
1652
|
+
if (useVertexColors)
|
|
1653
|
+
cacheKey += 'vertex-colors:';
|
|
1654
|
+
if (useFlatShading)
|
|
1655
|
+
cacheKey += 'flat-shading:';
|
|
1656
|
+
if (useMorphTargets)
|
|
1657
|
+
cacheKey += 'morph-targets:';
|
|
1658
|
+
if (useMorphNormals)
|
|
1659
|
+
cacheKey += 'morph-normals:';
|
|
1660
|
+
let cachedMaterial = this.cache.get(cacheKey);
|
|
1661
|
+
if (!cachedMaterial) {
|
|
1662
|
+
cachedMaterial = material.clone();
|
|
1663
|
+
if (useSkinning)
|
|
1664
|
+
cachedMaterial.skinning = true;
|
|
1665
|
+
if (useVertexColors)
|
|
1666
|
+
cachedMaterial.vertexColors = true;
|
|
1667
|
+
if (useFlatShading)
|
|
1668
|
+
cachedMaterial.flatShading = true;
|
|
1669
|
+
if (useMorphTargets)
|
|
1670
|
+
cachedMaterial.morphTargets = true;
|
|
1671
|
+
if (useMorphNormals)
|
|
1672
|
+
cachedMaterial.morphNormals = true;
|
|
1673
|
+
if (useVertexTangents) {
|
|
1674
|
+
cachedMaterial.vertexTangents = true;
|
|
1675
|
+
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
|
|
1676
|
+
if (cachedMaterial.normalScale)
|
|
1677
|
+
cachedMaterial.normalScale.y *= -1;
|
|
1678
|
+
if (cachedMaterial.clearcoatNormalScale)
|
|
1679
|
+
cachedMaterial.clearcoatNormalScale.y *= -1;
|
|
1680
|
+
}
|
|
1681
|
+
this.cache.add(cacheKey, cachedMaterial);
|
|
1682
|
+
this.associations.set(cachedMaterial, this.associations.get(material));
|
|
1683
|
+
}
|
|
1684
|
+
material = cachedMaterial;
|
|
1685
|
+
}
|
|
1686
|
+
// workarounds for mesh and geometry
|
|
1687
|
+
if (material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined) {
|
|
1688
|
+
geometry.setAttribute('uv2', geometry.attributes.uv);
|
|
1689
|
+
}
|
|
1690
|
+
mesh.material = material;
|
|
1691
|
+
}
|
|
1692
|
+
getMaterialType( /* materialIndex */) {
|
|
1693
|
+
const { THREE } = Externals.getInstance();
|
|
1694
|
+
return THREE.MeshStandardMaterial;
|
|
1695
|
+
}
|
|
1696
|
+
loadMaterial(materialIndex) {
|
|
1697
|
+
const parser = this;
|
|
1698
|
+
const json = this.json;
|
|
1699
|
+
const extensions = this.extensions;
|
|
1700
|
+
const materialDef = json.materials[materialIndex];
|
|
1701
|
+
let materialType;
|
|
1702
|
+
const materialParams = {};
|
|
1703
|
+
const materialExtensions = materialDef.extensions || {};
|
|
1704
|
+
const pending = [];
|
|
1705
|
+
const { THREE } = Externals.getInstance();
|
|
1706
|
+
if (materialExtensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {
|
|
1707
|
+
const sgExtension = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];
|
|
1708
|
+
materialType = sgExtension.getMaterialType();
|
|
1709
|
+
pending.push(sgExtension.extendParams(materialParams, materialDef, parser));
|
|
1710
|
+
}
|
|
1711
|
+
else if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {
|
|
1712
|
+
const kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];
|
|
1713
|
+
materialType = kmuExtension.getMaterialType();
|
|
1714
|
+
pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));
|
|
1715
|
+
}
|
|
1716
|
+
else {
|
|
1717
|
+
// Specification:
|
|
1718
|
+
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
|
|
1719
|
+
const metallicRoughness = materialDef.pbrMetallicRoughness || {};
|
|
1720
|
+
materialParams.color = new THREE.Color(1.0, 1.0, 1.0);
|
|
1721
|
+
materialParams.opacity = 1.0;
|
|
1722
|
+
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
1723
|
+
const array = metallicRoughness.baseColorFactor;
|
|
1724
|
+
materialParams.color.fromArray(array);
|
|
1725
|
+
materialParams.opacity = array[3];
|
|
1726
|
+
}
|
|
1727
|
+
if (metallicRoughness.baseColorTexture !== undefined) {
|
|
1728
|
+
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture));
|
|
1729
|
+
}
|
|
1730
|
+
materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
|
|
1731
|
+
materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
|
|
1732
|
+
if (metallicRoughness.metallicRoughnessTexture !== undefined) {
|
|
1733
|
+
pending.push(parser.assignTexture(materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture));
|
|
1734
|
+
pending.push(parser.assignTexture(materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture));
|
|
1735
|
+
}
|
|
1736
|
+
materialType = this._invokeOne((ext) => ext.getMaterialType && ext.getMaterialType(materialIndex));
|
|
1737
|
+
pending.push(Promise.all(this._invokeAll((ext) => ext.extendMaterialParams && ext.extendMaterialParams(materialIndex, materialParams))));
|
|
1738
|
+
}
|
|
1739
|
+
if (materialDef.doubleSided === true) {
|
|
1740
|
+
materialParams.side = THREE.DoubleSide;
|
|
1741
|
+
}
|
|
1742
|
+
const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
|
|
1743
|
+
if (alphaMode === ALPHA_MODES.BLEND) {
|
|
1744
|
+
materialParams.transparent = true;
|
|
1745
|
+
// See: https://github.com/mrdoob/three.js/issues/17706
|
|
1746
|
+
materialParams.depthWrite = false;
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
materialParams.transparent = false;
|
|
1750
|
+
if (alphaMode === ALPHA_MODES.MASK) {
|
|
1751
|
+
materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial) {
|
|
1755
|
+
pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture));
|
|
1756
|
+
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
|
|
1757
|
+
materialParams.normalScale = new THREE.Vector2(1, -1);
|
|
1758
|
+
if (materialDef.normalTexture.scale !== undefined) {
|
|
1759
|
+
materialParams.normalScale.set(materialDef.normalTexture.scale, -materialDef.normalTexture.scale);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
if (materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial) {
|
|
1763
|
+
pending.push(parser.assignTexture(materialParams, 'aoMap', materialDef.occlusionTexture));
|
|
1764
|
+
if (materialDef.occlusionTexture.strength !== undefined) {
|
|
1765
|
+
materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
if (materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial) {
|
|
1769
|
+
materialParams.emissive = new THREE.Color().fromArray(materialDef.emissiveFactor);
|
|
1770
|
+
}
|
|
1771
|
+
if (materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial) {
|
|
1772
|
+
pending.push(parser.assignTexture(materialParams, 'emissiveMap', materialDef.emissiveTexture));
|
|
1773
|
+
}
|
|
1774
|
+
return Promise.all(pending).then(() => {
|
|
1775
|
+
let material;
|
|
1776
|
+
if (materialType === GLTFMeshStandardSGMaterial) {
|
|
1777
|
+
material = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(materialParams);
|
|
1778
|
+
}
|
|
1779
|
+
else {
|
|
1780
|
+
material = new materialType(materialParams);
|
|
1781
|
+
}
|
|
1782
|
+
if (materialDef.name)
|
|
1783
|
+
material.name = materialDef.name;
|
|
1784
|
+
// baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
|
|
1785
|
+
if (material.map)
|
|
1786
|
+
material.map.encoding = THREE.sRGBEncoding;
|
|
1787
|
+
if (material.emissiveMap)
|
|
1788
|
+
material.emissiveMap.encoding = THREE.sRGBEncoding;
|
|
1789
|
+
assignExtrasToUserData(material, materialDef);
|
|
1790
|
+
parser.associations.set(material, { type: 'materials', index: materialIndex });
|
|
1791
|
+
if (materialDef.extensions)
|
|
1792
|
+
addUnknownExtensionsToUserData(extensions, material, materialDef);
|
|
1793
|
+
return material;
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
createUniqueName(originalName) {
|
|
1797
|
+
const { THREE } = Externals.getInstance();
|
|
1798
|
+
const sanitizedName = THREE.PropertyBinding.sanitizeNodeName(originalName || '');
|
|
1799
|
+
let name = sanitizedName;
|
|
1800
|
+
for (let i = 1; this.nodeNamesUsed[name]; ++i) {
|
|
1801
|
+
name = `${sanitizedName}_${i}`;
|
|
1802
|
+
}
|
|
1803
|
+
this.nodeNamesUsed[name] = true;
|
|
1804
|
+
return name;
|
|
1805
|
+
}
|
|
1806
|
+
loadGeometries(primitives) {
|
|
1807
|
+
const parser = this;
|
|
1808
|
+
const extensions = this.extensions;
|
|
1809
|
+
const cache = this.primitiveCache;
|
|
1810
|
+
function createDracoPrimitive(primitive) {
|
|
1811
|
+
return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]
|
|
1812
|
+
.decodePrimitive(primitive, parser)
|
|
1813
|
+
.then((geometry) => addPrimitiveAttributes(geometry, primitive, parser));
|
|
1814
|
+
}
|
|
1815
|
+
const pending = [];
|
|
1816
|
+
const { THREE } = Externals.getInstance();
|
|
1817
|
+
for (let i = 0, il = primitives.length; i < il; i++) {
|
|
1818
|
+
const primitive = primitives[i];
|
|
1819
|
+
const cacheKey = createPrimitiveKey(primitive);
|
|
1820
|
+
// See if we've already created this geometry
|
|
1821
|
+
const cached = cache[cacheKey];
|
|
1822
|
+
if (cached) {
|
|
1823
|
+
// Use the cached geometry if it exists
|
|
1824
|
+
pending.push(cached.promise);
|
|
1825
|
+
}
|
|
1826
|
+
else {
|
|
1827
|
+
let geometryPromise;
|
|
1828
|
+
if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {
|
|
1829
|
+
// Use DRACO geometry if available
|
|
1830
|
+
geometryPromise = createDracoPrimitive(primitive);
|
|
1831
|
+
}
|
|
1832
|
+
else {
|
|
1833
|
+
// Otherwise create a new geometry
|
|
1834
|
+
geometryPromise = addPrimitiveAttributes(new THREE.BufferGeometry(), primitive, parser);
|
|
1835
|
+
}
|
|
1836
|
+
// Cache this geometry
|
|
1837
|
+
cache[cacheKey] = { primitive, promise: geometryPromise };
|
|
1838
|
+
pending.push(geometryPromise);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
return Promise.all(pending);
|
|
1842
|
+
}
|
|
1843
|
+
loadMesh(meshIndex) {
|
|
1844
|
+
const parser = this;
|
|
1845
|
+
const json = this.json;
|
|
1846
|
+
const extensions = this.extensions;
|
|
1847
|
+
const meshDef = json.meshes[meshIndex];
|
|
1848
|
+
const primitives = meshDef.primitives;
|
|
1849
|
+
const pending = [];
|
|
1850
|
+
const { THREE } = Externals.getInstance();
|
|
1851
|
+
for (let i = 0, il = primitives.length; i < il; i++) {
|
|
1852
|
+
const material = primitives[i].material === undefined
|
|
1853
|
+
? createDefaultMaterial(this.cache)
|
|
1854
|
+
: this.getDependency('material', primitives[i].material);
|
|
1855
|
+
pending.push(material);
|
|
1856
|
+
}
|
|
1857
|
+
pending.push(parser.loadGeometries(primitives));
|
|
1858
|
+
return Promise.all(pending).then((results) => {
|
|
1859
|
+
const materials = results.slice(0, results.length - 1);
|
|
1860
|
+
const geometries = results[results.length - 1];
|
|
1861
|
+
const meshes = [];
|
|
1862
|
+
for (let i = 0, il = geometries.length; i < il; i++) {
|
|
1863
|
+
const geometry = geometries[i];
|
|
1864
|
+
const primitive = primitives[i];
|
|
1865
|
+
// 1. create Mesh
|
|
1866
|
+
let mesh;
|
|
1867
|
+
const material = materials[i];
|
|
1868
|
+
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES
|
|
1869
|
+
|| primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP
|
|
1870
|
+
|| primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN
|
|
1871
|
+
|| primitive.mode === undefined) {
|
|
1872
|
+
// .isSkinnedMesh isn't in glTF spec. See ._markDefs()
|
|
1873
|
+
mesh = meshDef.isSkinnedMesh === true
|
|
1874
|
+
? new THREE.SkinnedMesh(geometry, material)
|
|
1875
|
+
: new THREE.Mesh(geometry, material);
|
|
1876
|
+
if (mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized) {
|
|
1877
|
+
// we normalize floating point skin weight array to fix malformed assets (see #15319)
|
|
1878
|
+
// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
|
|
1879
|
+
mesh.normalizeSkinWeights();
|
|
1880
|
+
}
|
|
1881
|
+
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
|
|
1882
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, THREE.TriangleStripDrawMode);
|
|
1883
|
+
}
|
|
1884
|
+
else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
|
|
1885
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, THREE.TriangleFanDrawMode);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
|
|
1889
|
+
mesh = new THREE.LineSegments(geometry, material);
|
|
1890
|
+
}
|
|
1891
|
+
else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
|
|
1892
|
+
mesh = new THREE.Line(geometry, material);
|
|
1893
|
+
}
|
|
1894
|
+
else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
|
|
1895
|
+
mesh = new THREE.LineLoop(geometry, material);
|
|
1896
|
+
}
|
|
1897
|
+
else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
|
|
1898
|
+
mesh = new THREE.Points(geometry, material);
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
throw new Error(`THREE.GLTFLoader: Primitive mode unsupported: ${primitive.mode}`);
|
|
1902
|
+
}
|
|
1903
|
+
if (Object.keys(mesh.geometry.morphAttributes).length > 0) {
|
|
1904
|
+
updateMorphTargets(mesh, meshDef);
|
|
1905
|
+
}
|
|
1906
|
+
mesh.name = parser.createUniqueName(meshDef.name || (`mesh_${meshIndex}`));
|
|
1907
|
+
assignExtrasToUserData(mesh, meshDef);
|
|
1908
|
+
if (primitive.extensions)
|
|
1909
|
+
addUnknownExtensionsToUserData(extensions, mesh, primitive);
|
|
1910
|
+
parser.assignFinalMaterial(mesh);
|
|
1911
|
+
meshes.push(mesh);
|
|
1912
|
+
}
|
|
1913
|
+
if (meshes.length === 1) {
|
|
1914
|
+
return meshes[0];
|
|
1915
|
+
}
|
|
1916
|
+
const group = new THREE.Group();
|
|
1917
|
+
for (let i = 0, il = meshes.length; i < il; i++) {
|
|
1918
|
+
group.add(meshes[i]);
|
|
1919
|
+
}
|
|
1920
|
+
return group;
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
loadCamera(cameraIndex) {
|
|
1924
|
+
let camera;
|
|
1925
|
+
const cameraDef = this.json.cameras[cameraIndex];
|
|
1926
|
+
const params = cameraDef[cameraDef.type];
|
|
1927
|
+
const { THREE } = Externals.getInstance();
|
|
1928
|
+
if (!params) {
|
|
1929
|
+
console.warn('THREE.GLTFLoader: Missing camera parameters.');
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
if (cameraDef.type === 'perspective') {
|
|
1933
|
+
camera = new THREE.PerspectiveCamera(THREE.MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
|
|
1934
|
+
}
|
|
1935
|
+
else if (cameraDef.type === 'orthographic') {
|
|
1936
|
+
camera = new THREE.OrthographicCamera(-params.xmag, params.xmag, params.ymag, -params.ymag, params.znear, params.zfar);
|
|
1937
|
+
}
|
|
1938
|
+
if (cameraDef.name)
|
|
1939
|
+
camera.name = this.createUniqueName(cameraDef.name);
|
|
1940
|
+
assignExtrasToUserData(camera, cameraDef);
|
|
1941
|
+
return Promise.resolve(camera);
|
|
1942
|
+
}
|
|
1943
|
+
loadSkin(skinIndex) {
|
|
1944
|
+
const skinDef = this.json.skins[skinIndex];
|
|
1945
|
+
const skinEntry = { joints: skinDef.joints };
|
|
1946
|
+
if (skinDef.inverseBindMatrices === undefined) {
|
|
1947
|
+
return Promise.resolve(skinEntry);
|
|
1948
|
+
}
|
|
1949
|
+
return this.getDependency('accessor', skinDef.inverseBindMatrices).then((accessor) => {
|
|
1950
|
+
skinEntry.inverseBindMatrices = accessor;
|
|
1951
|
+
return skinEntry;
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
loadAnimation(animationIndex) {
|
|
1955
|
+
const json = this.json;
|
|
1956
|
+
const animationDef = json.animations[animationIndex];
|
|
1957
|
+
const pendingNodes = [];
|
|
1958
|
+
const pendingInputAccessors = [];
|
|
1959
|
+
const pendingOutputAccessors = [];
|
|
1960
|
+
const pendingSamplers = [];
|
|
1961
|
+
const pendingTargets = [];
|
|
1962
|
+
const { THREE } = Externals.getInstance();
|
|
1963
|
+
for (let i = 0, il = animationDef.channels.length; i < il; i++) {
|
|
1964
|
+
const channel = animationDef.channels[i];
|
|
1965
|
+
const sampler = animationDef.samplers[channel.sampler];
|
|
1966
|
+
const target = channel.target;
|
|
1967
|
+
const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
|
|
1968
|
+
const input = animationDef.parameters !== undefined ? animationDef.parameters[sampler.input] : sampler.input;
|
|
1969
|
+
const output = animationDef.parameters !== undefined ? animationDef.parameters[sampler.output] : sampler.output;
|
|
1970
|
+
pendingNodes.push(this.getDependency('node', name));
|
|
1971
|
+
pendingInputAccessors.push(this.getDependency('accessor', input));
|
|
1972
|
+
pendingOutputAccessors.push(this.getDependency('accessor', output));
|
|
1973
|
+
pendingSamplers.push(sampler);
|
|
1974
|
+
pendingTargets.push(target);
|
|
1975
|
+
}
|
|
1976
|
+
return Promise.all([
|
|
1977
|
+
Promise.all(pendingNodes),
|
|
1978
|
+
Promise.all(pendingInputAccessors),
|
|
1979
|
+
Promise.all(pendingOutputAccessors),
|
|
1980
|
+
Promise.all(pendingSamplers),
|
|
1981
|
+
Promise.all(pendingTargets),
|
|
1982
|
+
]).then((dependencies) => {
|
|
1983
|
+
const nodes = dependencies[0];
|
|
1984
|
+
const inputAccessors = dependencies[1];
|
|
1985
|
+
const outputAccessors = dependencies[2];
|
|
1986
|
+
const samplers = dependencies[3];
|
|
1987
|
+
const targets = dependencies[4];
|
|
1988
|
+
const tracks = [];
|
|
1989
|
+
for (let i = 0, il = nodes.length; i < il; i++) {
|
|
1990
|
+
const node = nodes[i];
|
|
1991
|
+
const inputAccessor = inputAccessors[i];
|
|
1992
|
+
const outputAccessor = outputAccessors[i];
|
|
1993
|
+
const sampler = samplers[i];
|
|
1994
|
+
const target = targets[i];
|
|
1995
|
+
if (node === undefined)
|
|
1996
|
+
continue;
|
|
1997
|
+
node.updateMatrix();
|
|
1998
|
+
node.matrixAutoUpdate = true;
|
|
1999
|
+
let TypedKeyframeTrack;
|
|
2000
|
+
switch (PATH_PROPERTIES[target.path]) {
|
|
2001
|
+
case PATH_PROPERTIES.weights:
|
|
2002
|
+
TypedKeyframeTrack = THREE.NumberKeyframeTrack;
|
|
2003
|
+
break;
|
|
2004
|
+
case PATH_PROPERTIES.rotation:
|
|
2005
|
+
TypedKeyframeTrack = THREE.QuaternionKeyframeTrack;
|
|
2006
|
+
break;
|
|
2007
|
+
case PATH_PROPERTIES.position:
|
|
2008
|
+
case PATH_PROPERTIES.scale:
|
|
2009
|
+
default:
|
|
2010
|
+
TypedKeyframeTrack = THREE.VectorKeyframeTrack;
|
|
2011
|
+
break;
|
|
2012
|
+
}
|
|
2013
|
+
const targetName = node.name ? node.name : node.uuid;
|
|
2014
|
+
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[sampler.interpolation] : THREE.InterpolateLinear;
|
|
2015
|
+
const targetNames = [];
|
|
2016
|
+
if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
|
|
2017
|
+
// Node may be a Group (glTF mesh with several primitives) or a Mesh.
|
|
2018
|
+
node.traverse((object) => {
|
|
2019
|
+
if (object.isMesh === true && object.morphTargetInfluences) {
|
|
2020
|
+
targetNames.push(object.name ? object.name : object.uuid);
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
targetNames.push(targetName);
|
|
2026
|
+
}
|
|
2027
|
+
let outputArray = outputAccessor.array;
|
|
2028
|
+
if (outputAccessor.normalized) {
|
|
2029
|
+
let scale;
|
|
2030
|
+
if (outputArray.constructor === Int8Array) {
|
|
2031
|
+
scale = 1 / 127;
|
|
2032
|
+
}
|
|
2033
|
+
else if (outputArray.constructor === Uint8Array) {
|
|
2034
|
+
scale = 1 / 255;
|
|
2035
|
+
}
|
|
2036
|
+
else if (outputArray.constructor === Int16Array) {
|
|
2037
|
+
scale = 1 / 32767;
|
|
2038
|
+
}
|
|
2039
|
+
else if (outputArray.constructor === Uint16Array) {
|
|
2040
|
+
scale = 1 / 65535;
|
|
2041
|
+
}
|
|
2042
|
+
else {
|
|
2043
|
+
throw new Error('THREE.GLTFLoader: Unsupported output accessor component type.');
|
|
2044
|
+
}
|
|
2045
|
+
const scaled = new Float32Array(outputArray.length);
|
|
2046
|
+
for (let j = 0, jl = outputArray.length; j < jl; j++) {
|
|
2047
|
+
scaled[j] = outputArray[j] * scale;
|
|
2048
|
+
}
|
|
2049
|
+
outputArray = scaled;
|
|
2050
|
+
}
|
|
2051
|
+
for (let j = 0, jl = targetNames.length; j < jl; j++) {
|
|
2052
|
+
const track = new TypedKeyframeTrack(`${targetNames[j]}.${PATH_PROPERTIES[target.path]}`, inputAccessor.array, outputArray, interpolation);
|
|
2053
|
+
// Override interpolation with custom factory method.
|
|
2054
|
+
if (sampler.interpolation === 'CUBICSPLINE') {
|
|
2055
|
+
track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
|
|
2056
|
+
// A CUBICSPLINE keyframe in glTF has three output values for each input value,
|
|
2057
|
+
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
|
2058
|
+
// must be divided by three to get the interpolant's sampleSize argument.
|
|
2059
|
+
return new GLTFCubicSplineInterpolant(this.times, this.values, this.getValueSize() / 3, result);
|
|
2060
|
+
};
|
|
2061
|
+
// Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
|
|
2062
|
+
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
|
|
2063
|
+
}
|
|
2064
|
+
tracks.push(track);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
const name = animationDef.name ? animationDef.name : `animation_${animationIndex}`;
|
|
2068
|
+
return new THREE.AnimationClip(name, undefined, tracks);
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
loadNode(nodeIndex) {
|
|
2072
|
+
const json = this.json;
|
|
2073
|
+
const extensions = this.extensions;
|
|
2074
|
+
const parser = this;
|
|
2075
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
2076
|
+
// reserve node's name before its dependencies, so the root has the intended name.
|
|
2077
|
+
const nodeName = nodeDef.name ? parser.createUniqueName(nodeDef.name) : '';
|
|
2078
|
+
const { THREE } = Externals.getInstance();
|
|
2079
|
+
return (function () {
|
|
2080
|
+
const pending = [];
|
|
2081
|
+
if (nodeDef.mesh !== undefined) {
|
|
2082
|
+
pending.push(parser.getDependency('mesh', nodeDef.mesh).then((mesh) => {
|
|
2083
|
+
const node = parser._getNodeRef(parser.meshCache, nodeDef.mesh, mesh);
|
|
2084
|
+
// if weights are provided on the node, override weights on the mesh.
|
|
2085
|
+
if (nodeDef.weights !== undefined) {
|
|
2086
|
+
node.traverse((o) => {
|
|
2087
|
+
if (!o.isMesh)
|
|
2088
|
+
return;
|
|
2089
|
+
for (let i = 0, il = nodeDef.weights.length; i < il; i++) {
|
|
2090
|
+
o.morphTargetInfluences[i] = nodeDef.weights[i];
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
return node;
|
|
2095
|
+
}));
|
|
2096
|
+
}
|
|
2097
|
+
if (nodeDef.camera !== undefined) {
|
|
2098
|
+
pending.push(parser.getDependency('camera', nodeDef.camera).then((camera) => parser._getNodeRef(parser.cameraCache, nodeDef.camera, camera)));
|
|
2099
|
+
}
|
|
2100
|
+
parser._invokeAll((ext) => ext.createNodeAttachment && ext.createNodeAttachment(nodeIndex)).forEach((promise) => {
|
|
2101
|
+
pending.push(promise);
|
|
2102
|
+
});
|
|
2103
|
+
return Promise.all(pending);
|
|
2104
|
+
}()).then((objects) => {
|
|
2105
|
+
let node;
|
|
2106
|
+
// .isBone isn't in glTF spec. See ._markDefs
|
|
2107
|
+
if (nodeDef.isBone === true) {
|
|
2108
|
+
node = new THREE.Bone();
|
|
2109
|
+
}
|
|
2110
|
+
else if (objects.length > 1) {
|
|
2111
|
+
node = new THREE.Group();
|
|
2112
|
+
}
|
|
2113
|
+
else if (objects.length === 1) {
|
|
2114
|
+
node = objects[0];
|
|
2115
|
+
}
|
|
2116
|
+
else {
|
|
2117
|
+
node = new THREE.Object3D();
|
|
2118
|
+
}
|
|
2119
|
+
if (node !== objects[0]) {
|
|
2120
|
+
for (let i = 0, il = objects.length; i < il; i++) {
|
|
2121
|
+
node.add(objects[i]);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
if (nodeDef.name) {
|
|
2125
|
+
node.userData.name = nodeDef.name;
|
|
2126
|
+
node.name = nodeName;
|
|
2127
|
+
}
|
|
2128
|
+
assignExtrasToUserData(node, nodeDef);
|
|
2129
|
+
if (nodeDef.extensions)
|
|
2130
|
+
addUnknownExtensionsToUserData(extensions, node, nodeDef);
|
|
2131
|
+
if (nodeDef.matrix !== undefined) {
|
|
2132
|
+
const matrix = new THREE.Matrix4();
|
|
2133
|
+
matrix.fromArray(nodeDef.matrix);
|
|
2134
|
+
node.applyMatrix4(matrix);
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
if (nodeDef.translation !== undefined) {
|
|
2138
|
+
node.position.fromArray(nodeDef.translation);
|
|
2139
|
+
}
|
|
2140
|
+
if (nodeDef.rotation !== undefined) {
|
|
2141
|
+
node.quaternion.fromArray(nodeDef.rotation);
|
|
2142
|
+
}
|
|
2143
|
+
if (nodeDef.scale !== undefined) {
|
|
2144
|
+
node.scale.fromArray(nodeDef.scale);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
parser.associations.set(node, { type: 'nodes', index: nodeIndex });
|
|
2148
|
+
return node;
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
class GLTFLoader extends NS_THREE.Loader {
|
|
2153
|
+
constructor(manager) {
|
|
2154
|
+
super(manager);
|
|
2155
|
+
this.dracoLoader = null;
|
|
2156
|
+
this.ktx2Loader = null;
|
|
2157
|
+
this.meshoptDecoder = null;
|
|
2158
|
+
this.pluginCallbacks = [];
|
|
2159
|
+
this.register((parser) => new GLTFMaterialsClearcoatExtension(parser));
|
|
2160
|
+
this.register((parser) => new GLTFTextureBasisUExtension(parser));
|
|
2161
|
+
this.register((parser) => new GLTFTextureWebPExtension(parser));
|
|
2162
|
+
this.register((parser) => new GLTFMaterialsTransmissionExtension(parser));
|
|
2163
|
+
this.register((parser) => new GLTFLightsExtension(parser));
|
|
2164
|
+
this.register((parser) => new GLTFMeshoptCompression(parser));
|
|
2165
|
+
}
|
|
2166
|
+
load(url, onLoad, onProgress, onError) {
|
|
2167
|
+
const scope = this;
|
|
2168
|
+
let resourcePath;
|
|
2169
|
+
const { THREE } = Externals.getInstance();
|
|
2170
|
+
if (this.resourcePath !== '') {
|
|
2171
|
+
resourcePath = this.resourcePath;
|
|
2172
|
+
}
|
|
2173
|
+
else if (this.path !== '') {
|
|
2174
|
+
resourcePath = this.path;
|
|
2175
|
+
}
|
|
2176
|
+
else {
|
|
2177
|
+
resourcePath = THREE.LoaderUtils.extractUrlBase(url);
|
|
2178
|
+
}
|
|
2179
|
+
// Tells the LoadingManager to track an extra item, which resolves after
|
|
2180
|
+
// the model is fully loaded. This means the count of items loaded will
|
|
2181
|
+
// be incorrect, but ensures manager.onLoad() does not fire early.
|
|
2182
|
+
this.manager.itemStart(url);
|
|
2183
|
+
const _onError = function (e) {
|
|
2184
|
+
if (onError) {
|
|
2185
|
+
onError(e);
|
|
2186
|
+
}
|
|
2187
|
+
else {
|
|
2188
|
+
console.error(e);
|
|
2189
|
+
}
|
|
2190
|
+
scope.manager.itemError(url);
|
|
2191
|
+
scope.manager.itemEnd(url);
|
|
2192
|
+
};
|
|
2193
|
+
const loader = new THREE.FileLoader(this.manager);
|
|
2194
|
+
loader.setPath(this.path);
|
|
2195
|
+
loader.setResponseType('arraybuffer');
|
|
2196
|
+
loader.setRequestHeader(this.requestHeader);
|
|
2197
|
+
loader.setWithCredentials(this.withCredentials);
|
|
2198
|
+
loader.load(url, (data) => {
|
|
2199
|
+
try {
|
|
2200
|
+
scope.parse(data, resourcePath, (gltf) => {
|
|
2201
|
+
onLoad(gltf);
|
|
2202
|
+
scope.manager.itemEnd(url);
|
|
2203
|
+
}, _onError);
|
|
2204
|
+
}
|
|
2205
|
+
catch (e) {
|
|
2206
|
+
_onError(e);
|
|
2207
|
+
}
|
|
2208
|
+
}, onProgress, _onError);
|
|
2209
|
+
}
|
|
2210
|
+
setDRACOLoader(dracoLoader) {
|
|
2211
|
+
this.dracoLoader = dracoLoader;
|
|
2212
|
+
return this;
|
|
2213
|
+
}
|
|
2214
|
+
setDDSLoader() {
|
|
2215
|
+
throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".');
|
|
2216
|
+
}
|
|
2217
|
+
setKTX2Loader(ktx2Loader) {
|
|
2218
|
+
this.ktx2Loader = ktx2Loader;
|
|
2219
|
+
return this;
|
|
2220
|
+
}
|
|
2221
|
+
setMeshoptDecoder(meshoptDecoder) {
|
|
2222
|
+
this.meshoptDecoder = meshoptDecoder;
|
|
2223
|
+
return this;
|
|
2224
|
+
}
|
|
2225
|
+
register(callback) {
|
|
2226
|
+
if (this.pluginCallbacks.indexOf(callback) === -1) {
|
|
2227
|
+
this.pluginCallbacks.push(callback);
|
|
2228
|
+
}
|
|
2229
|
+
return this;
|
|
2230
|
+
}
|
|
2231
|
+
unregister(callback) {
|
|
2232
|
+
if (this.pluginCallbacks.indexOf(callback) !== -1) {
|
|
2233
|
+
this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback), 1);
|
|
2234
|
+
}
|
|
2235
|
+
return this;
|
|
2236
|
+
}
|
|
2237
|
+
parse(data, path, onLoad, onError) {
|
|
2238
|
+
let content;
|
|
2239
|
+
const extensions = {};
|
|
2240
|
+
const plugins = {};
|
|
2241
|
+
const { THREE } = Externals.getInstance();
|
|
2242
|
+
if (typeof data === 'string') {
|
|
2243
|
+
content = data;
|
|
2244
|
+
}
|
|
2245
|
+
else {
|
|
2246
|
+
const magic = THREE.LoaderUtils.decodeText(new Uint8Array(data, 0, 4));
|
|
2247
|
+
if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
|
|
2248
|
+
try {
|
|
2249
|
+
extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
|
|
2250
|
+
}
|
|
2251
|
+
catch (error) {
|
|
2252
|
+
if (onError)
|
|
2253
|
+
onError(error);
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;
|
|
2257
|
+
}
|
|
2258
|
+
else {
|
|
2259
|
+
content = THREE.LoaderUtils.decodeText(new Uint8Array(data));
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
const json = JSON.parse(content);
|
|
2263
|
+
if (json.asset === undefined || json.asset.version[0] < 2) {
|
|
2264
|
+
if (onError)
|
|
2265
|
+
onError(new Error('THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.'));
|
|
2266
|
+
return;
|
|
2267
|
+
}
|
|
2268
|
+
const parser = new GLTFParser(json, {
|
|
2269
|
+
path: path || this.resourcePath || '',
|
|
2270
|
+
crossOrigin: this.crossOrigin,
|
|
2271
|
+
requestHeader: this.requestHeader,
|
|
2272
|
+
manager: this.manager,
|
|
2273
|
+
ktx2Loader: this.ktx2Loader,
|
|
2274
|
+
meshoptDecoder: this.meshoptDecoder,
|
|
2275
|
+
});
|
|
2276
|
+
parser.fileLoader.setRequestHeader(this.requestHeader);
|
|
2277
|
+
for (let i = 0; i < this.pluginCallbacks.length; i++) {
|
|
2278
|
+
const plugin = this.pluginCallbacks[i](parser);
|
|
2279
|
+
plugins[plugin.name] = plugin;
|
|
2280
|
+
// Workaround to avoid determining as unknown extension
|
|
2281
|
+
// in addUnknownExtensionsToUserData().
|
|
2282
|
+
// Remove this workaround if we move all the existing
|
|
2283
|
+
// extension handlers to plugin system
|
|
2284
|
+
extensions[plugin.name] = true;
|
|
2285
|
+
}
|
|
2286
|
+
if (json.extensionsUsed) {
|
|
2287
|
+
for (let i = 0; i < json.extensionsUsed.length; ++i) {
|
|
2288
|
+
const extensionName = json.extensionsUsed[i];
|
|
2289
|
+
const extensionsRequired = json.extensionsRequired || [];
|
|
2290
|
+
switch (extensionName) {
|
|
2291
|
+
case EXTENSIONS.KHR_MATERIALS_UNLIT:
|
|
2292
|
+
extensions[extensionName] = new GLTFMaterialsUnlitExtension();
|
|
2293
|
+
break;
|
|
2294
|
+
case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
|
|
2295
|
+
extensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();
|
|
2296
|
+
break;
|
|
2297
|
+
case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
|
|
2298
|
+
extensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);
|
|
2299
|
+
break;
|
|
2300
|
+
case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
|
|
2301
|
+
extensions[extensionName] = new GLTFTextureTransformExtension();
|
|
2302
|
+
break;
|
|
2303
|
+
case EXTENSIONS.KHR_MESH_QUANTIZATION:
|
|
2304
|
+
extensions[extensionName] = new GLTFMeshQuantizationExtension();
|
|
2305
|
+
break;
|
|
2306
|
+
default:
|
|
2307
|
+
if (extensionsRequired.indexOf(extensionName) >= 0 && plugins[extensionName] === undefined) {
|
|
2308
|
+
console.warn(`THREE.GLTFLoader: Unknown extension "${extensionName}".`);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
parser.setExtensions(extensions);
|
|
2314
|
+
parser.setPlugins(plugins);
|
|
2315
|
+
parser.parse(onLoad, onError);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
export { GLTFLoader };
|