viral-viewer-2 6.2.7 → 6.2.8
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/LICENSE +5 -52
- package/dist/components/animation/viral-animation.js +71 -0
- package/dist/components/animation/viral-animation.js.map +1 -0
- package/dist/components/bvh/viral-bvh.js +19 -0
- package/dist/components/bvh/viral-bvh.js.map +1 -0
- package/dist/components/camera/viral-camera.d.ts +1 -1
- package/dist/components/camera/viral-camera.js +207 -0
- package/dist/components/camera/viral-camera.js.map +1 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.d.ts +7 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js +47 -0
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js.map +1 -0
- package/dist/components/compress/compress.processor.d.ts +4 -0
- package/dist/components/compress/compress.processor.js +29 -0
- package/dist/components/compress/compress.processor.js.map +1 -0
- package/dist/components/compress/viral-compress.processor.js +13 -0
- package/dist/components/compress/viral-compress.processor.js.map +1 -0
- package/dist/components/context-menu/viral-context-menu.d.ts +17 -0
- package/dist/components/context-menu/viral-context-menu.js +74 -0
- package/dist/components/context-menu/viral-context-menu.js.map +1 -0
- package/dist/components/custom-objects/index.js +6 -0
- package/dist/components/custom-objects/index.js.map +1 -0
- package/dist/components/custom-objects/viral-instanced-mesh.d.ts +1 -1
- package/dist/components/custom-objects/viral-instanced-mesh.js +203 -0
- package/dist/components/custom-objects/viral-instanced-mesh.js.map +1 -0
- package/dist/components/custom-objects/viral-mesh.d.ts +9 -0
- package/dist/components/custom-objects/viral-mesh.js +25 -0
- package/dist/components/custom-objects/viral-mesh.js.map +1 -0
- package/dist/components/data-manager/viral-data-manager.js +35 -0
- package/dist/components/data-manager/viral-data-manager.js.map +1 -0
- package/dist/components/event-handler/base/event-dispatcher.js +35 -0
- package/dist/components/event-handler/base/event-dispatcher.js.map +1 -0
- package/dist/components/event-handler/keyboard/viral-keyboard.js +78 -0
- package/dist/components/event-handler/keyboard/viral-keyboard.js.map +1 -0
- package/dist/components/event-handler/mouse/viral-mouse.js +239 -0
- package/dist/components/event-handler/mouse/viral-mouse.js.map +1 -0
- package/dist/components/event-handler/viral-centralized-event-handler.d.ts +2 -0
- package/dist/components/event-handler/viral-centralized-event-handler.js +186 -0
- package/dist/components/event-handler/viral-centralized-event-handler.js.map +1 -0
- package/dist/components/event-handler/viral-lifecycle-event-handler.js +55 -0
- package/dist/components/event-handler/viral-lifecycle-event-handler.js.map +1 -0
- package/dist/components/keyboard/viral-keyboard.d.ts +17 -0
- package/dist/components/keyboard/viral-keyboard.js +76 -0
- package/dist/components/keyboard/viral-keyboard.js.map +1 -0
- package/dist/components/loader/viral-point-cloud.loader.js +33 -0
- package/dist/components/loader/viral-point-cloud.loader.js.map +1 -0
- package/dist/components/loader/viral-revit.loader.d.ts +13 -1
- package/dist/components/loader/viral-revit.loader.js +339 -0
- package/dist/components/loader/viral-revit.loader.js.map +1 -0
- package/dist/components/loader/viral-three.loader.js +20 -0
- package/dist/components/loader/viral-three.loader.js.map +1 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.d.ts +16 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.js +33 -0
- package/dist/components/loader/viral-viewer-point-cloud.loader.js.map +1 -0
- package/dist/components/loader/viral-viewer-revit.loader.d.ts +13 -0
- package/dist/components/loader/viral-viewer-revit.loader.js +124 -0
- package/dist/components/loader/viral-viewer-revit.loader.js.map +1 -0
- package/dist/components/loader/viral.loader.js +16 -0
- package/dist/components/loader/viral.loader.js.map +1 -0
- package/dist/components/material/viral-material-manager.js +60 -0
- package/dist/components/material/viral-material-manager.js.map +1 -0
- package/dist/components/mouse/viral-mouse.d.ts +31 -0
- package/dist/components/mouse/viral-mouse.js +234 -0
- package/dist/components/mouse/viral-mouse.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-camera.d.ts +15 -0
- package/dist/components/navigation-cube/components/cube-camera.js +74 -0
- package/dist/components/navigation-cube/components/cube-camera.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-renderer.d.ts +9 -0
- package/dist/components/navigation-cube/components/cube-renderer.js +31 -0
- package/dist/components/navigation-cube/components/cube-renderer.js.map +1 -0
- package/dist/components/navigation-cube/components/cube-scene.d.ts +13 -0
- package/dist/components/navigation-cube/components/cube-scene.js +546 -0
- package/dist/components/navigation-cube/components/cube-scene.js.map +1 -0
- package/dist/components/navigation-cube/components/cube.mouse.d.ts +9 -0
- package/dist/components/navigation-cube/components/cube.mouse.js +109 -0
- package/dist/components/navigation-cube/components/cube.mouse.js.map +1 -0
- package/dist/components/navigation-cube/viral-navigation-cube.d.ts +16 -0
- package/dist/components/navigation-cube/viral-navigation-cube.js +50 -0
- package/dist/components/navigation-cube/viral-navigation-cube.js.map +1 -0
- package/dist/components/post-processing/ambient-occlusion-effect.d.ts +13 -0
- package/dist/components/post-processing/ambient-occlusion-effect.js +33 -0
- package/dist/components/post-processing/ambient-occlusion-effect.js.map +1 -0
- package/dist/components/post-processing/bloom-effect.d.ts +11 -0
- package/dist/components/post-processing/bloom-effect.js +29 -0
- package/dist/components/post-processing/bloom-effect.js.map +1 -0
- package/dist/components/post-processing/outline-effect.d.ts +13 -0
- package/dist/components/post-processing/outline-effect.js +33 -0
- package/dist/components/post-processing/outline-effect.js.map +1 -0
- package/dist/components/post-processing/post-processing-renderer.js +46 -0
- package/dist/components/post-processing/post-processing-renderer.js.map +1 -0
- package/dist/components/renderer/viral-renderer.js +55 -0
- package/dist/components/renderer/viral-renderer.js.map +1 -0
- package/dist/components/scene/viral-scene.d.ts +1 -0
- package/dist/components/scene/viral-scene.js +131 -0
- package/dist/components/scene/viral-scene.js.map +1 -0
- package/dist/components/spinner/viral-spinner.d.ts +10 -0
- package/dist/components/spinner/viral-spinner.js +207 -0
- package/dist/components/spinner/viral-spinner.js.map +1 -0
- package/dist/components/stats/viral-stats.js +17 -0
- package/dist/components/stats/viral-stats.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js +16 -0
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.js +21 -0
- package/dist/components/tools/tools/viral-tool-dark-mode.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-elevation.d.ts +11 -0
- package/dist/components/tools/tools/viral-tool-elevation.js +30 -0
- package/dist/components/tools/tools/viral-tool-elevation.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-measure.d.ts +33 -0
- package/dist/components/tools/tools/viral-tool-measure.js +243 -0
- package/dist/components/tools/tools/viral-tool-measure.js.map +1 -0
- package/dist/components/tools/tools/viral-tool-sunlight.d.ts +7 -0
- package/dist/components/tools/tools/viral-tool-sunlight.js +46 -0
- package/dist/components/tools/tools/viral-tool-sunlight.js.map +1 -0
- package/dist/components/tools/viral-tools.d.ts +32 -0
- package/dist/components/tools/viral-tools.js +213 -0
- package/dist/components/tools/viral-tools.js.map +1 -0
- package/dist/components/visibility-manager/viral-visibility-manager.js +175 -0
- package/dist/components/visibility-manager/viral-visibility-manager.js.map +1 -0
- package/dist/components/worker/base/worker-pool.js +68 -0
- package/dist/components/worker/base/worker-pool.js.map +1 -0
- package/dist/components/worker/base/worker-thread.js +35 -0
- package/dist/components/worker/base/worker-thread.js.map +1 -0
- package/dist/components/worker/fetch-data.worker.js +31 -0
- package/dist/components/worker/fetch-data.worker.js.map +1 -0
- package/dist/components/worker/load-element-by-material-v2.worker.d.ts +11 -0
- package/dist/components/worker/load-element-by-material-v2.worker.js +80 -0
- package/dist/components/worker/load-element-by-material-v2.worker.js.map +1 -0
- package/dist/components/worker/load-element-by-material.worker.d.ts +11 -0
- package/dist/components/worker/load-element-by-material.worker.js +59 -0
- package/dist/components/worker/load-element-by-material.worker.js.map +1 -0
- package/dist/components/worker/load-element-standalone.worker.d.ts +10 -0
- package/dist/components/worker/load-element-standalone.worker.js +109 -0
- package/dist/components/worker/load-element-standalone.worker.js.map +1 -0
- package/dist/components/worker/load-model.d.ts +126 -0
- package/dist/components/worker/load-model.js +1265 -0
- package/dist/components/worker/load-model.js.map +1 -0
- package/dist/components/worker/test-worker-pool.d.ts +6 -0
- package/dist/components/worker/test-worker-pool.js +21 -0
- package/dist/components/worker/test-worker-pool.js.map +1 -0
- package/dist/components/worker/viral-viewer-2.worker.js +127 -0
- package/dist/components/worker/viral-viewer-2.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer-3.worker.js +82 -0
- package/dist/components/worker/viral-viewer-3.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer-4.worker.js +97 -0
- package/dist/components/worker/viral-viewer-4.worker.js.map +1 -0
- package/dist/components/worker/viral-viewer.worker-pool.d.ts +0 -0
- package/dist/components/worker/viral-viewer.worker-pool.js +61 -0
- package/dist/components/worker/viral-viewer.worker-pool.js.map +1 -0
- package/dist/components/worker/viral-viewer.worker.js +107 -0
- package/dist/components/worker/viral-viewer.worker.js.map +1 -0
- package/dist/components/worker/worker-pool.d.ts +21 -0
- package/dist/components/worker/worker-pool.js +47 -0
- package/dist/components/worker/worker-pool.js.map +1 -0
- package/dist/components/worker/worker-thread.d.ts +9 -0
- package/dist/components/worker/worker-thread.js +30 -0
- package/dist/components/worker/worker-thread.js.map +1 -0
- package/dist/components/worker-script/fetch-data-worker.script.js +56 -0
- package/dist/components/worker-script/fetch-data-worker.script.js.map +1 -0
- package/dist/components/worker-script/load-element-by-material.script.d.ts +3 -0
- package/dist/components/worker-script/load-element-by-material.script.js +131 -0
- package/dist/components/worker-script/load-element-by-material.script.js.map +1 -0
- package/dist/components/worker-script/load-element-standalone.script.d.ts +1 -0
- package/dist/components/worker-script/load-element-standalone.script.js +34172 -0
- package/dist/components/worker-script/load-element-standalone.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker-2.script.js +2704 -0
- package/dist/components/worker-script/load-model-worker-2.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker-3.script.js +34170 -0
- package/dist/components/worker-script/load-model-worker-3.script.js.map +1 -0
- package/dist/components/worker-script/load-model-worker.script.js +148 -0
- package/dist/components/worker-script/load-model-worker.script.js.map +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.d.ts +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.js +34152 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-instanced-mesh.script.js.map +1 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.d.ts +3 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.js +127 -0
- package/dist/components/worker-script/material-aproach/load-element-by-material-mesh.script.js.map +1 -0
- package/dist/components/worker-script/test-worker-pool.script.d.ts +1 -0
- package/dist/components/worker-script/test-worker-pool.script.js +12 -0
- package/dist/components/worker-script/test-worker-pool.script.js.map +1 -0
- package/dist/components/worker-script/threejs.types.js +34162 -0
- package/dist/components/worker-script/threejs.types.js.map +1 -0
- package/dist/const/colors.d.ts +1 -0
- package/dist/const/colors.js +39 -0
- package/dist/const/colors.js.map +1 -0
- package/dist/const/fonts.js +17 -0
- package/dist/const/fonts.js.map +1 -0
- package/dist/const/icons.d.ts +7 -0
- package/dist/const/icons.js +11 -0
- package/dist/const/icons.js.map +1 -0
- package/dist/gui/context-menu/viral-context-menu.d.ts +1 -1
- package/dist/gui/context-menu/viral-context-menu.js +78 -0
- package/dist/gui/context-menu/viral-context-menu.js.map +1 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.d.ts +10 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.js +167 -0
- package/dist/gui/draggable-modal/viral-draggable-modal.js.map +1 -0
- package/dist/gui/fonts/fonts.js +20 -0
- package/dist/gui/fonts/fonts.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-camera.js +74 -0
- package/dist/gui/navigation-cube/components/cube-camera.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-renderer.js +31 -0
- package/dist/gui/navigation-cube/components/cube-renderer.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube-scene.js +546 -0
- package/dist/gui/navigation-cube/components/cube-scene.js.map +1 -0
- package/dist/gui/navigation-cube/components/cube.mouse.js +109 -0
- package/dist/gui/navigation-cube/components/cube.mouse.js.map +1 -0
- package/dist/gui/navigation-cube/viral-navigation-cube.js +50 -0
- package/dist/gui/navigation-cube/viral-navigation-cube.js.map +1 -0
- package/dist/gui/spinner/viral-spinner.js +102 -0
- package/dist/gui/spinner/viral-spinner.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js +25 -0
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-dark-mode.js +21 -0
- package/dist/gui/tools/tools/viral-tool-dark-mode.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-elevation.js +30 -0
- package/dist/gui/tools/tools/viral-tool-elevation.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.d.ts +7 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.js +36 -0
- package/dist/gui/tools/tools/viral-tool-export-scene.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-measure.js +243 -0
- package/dist/gui/tools/tools/viral-tool-measure.js.map +1 -0
- package/dist/gui/tools/tools/viral-tool-sunlight.js +46 -0
- package/dist/gui/tools/tools/viral-tool-sunlight.js.map +1 -0
- package/dist/gui/tools/viral-tools.js +213 -0
- package/dist/gui/tools/viral-tools.js.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/models/dictionary.model.d.ts +10 -0
- package/dist/models/dictionary.model.js +42 -0
- package/dist/models/dictionary.model.js.map +1 -0
- package/dist/services/local-storage.service.js +57 -0
- package/dist/services/local-storage.service.js.map +1 -0
- package/dist/threejs-addon/buffer-geometry-utils.d.ts +64 -0
- package/dist/threejs-addon/buffer-geometry-utils.js +807 -0
- package/dist/threejs-addon/buffer-geometry-utils.js.map +1 -0
- package/dist/threejs-addon/gltf-loader.d.ts +17 -0
- package/dist/threejs-addon/gltf-loader.js +2796 -0
- package/dist/threejs-addon/gltf-loader.js.map +1 -0
- package/dist/threejs-addon/n8ao/n8ao.js +1952 -0
- package/dist/threejs-addon/n8ao/n8ao.js.map +1 -0
- package/dist/threejs-addon/n8ao/post-processing.d.ts +109 -109
- package/dist/threejs-addon/n8ao/post-processing.js +15145 -0
- package/dist/threejs-addon/n8ao/post-processing.js.map +1 -0
- package/dist/threejs-addon/post-processing/effect-composer.d.ts +27 -0
- package/dist/threejs-addon/post-processing/effect-composer.js +134 -0
- package/dist/threejs-addon/post-processing/effect-composer.js.map +1 -0
- package/dist/threejs-addon/post-processing/mask-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/mask-pass.js +69 -0
- package/dist/threejs-addon/post-processing/mask-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/outline-pass.d.ts +58 -0
- package/dist/threejs-addon/post-processing/outline-pass.js +484 -0
- package/dist/threejs-addon/post-processing/outline-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/output-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/output-pass.js +61 -0
- package/dist/threejs-addon/post-processing/output-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/pass.d.ts +20 -0
- package/dist/threejs-addon/post-processing/pass.js +48 -0
- package/dist/threejs-addon/post-processing/pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/render-pass.d.ts +13 -0
- package/dist/threejs-addon/post-processing/render-pass.js +50 -0
- package/dist/threejs-addon/post-processing/render-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/sao-pass.d.ts +62 -0
- package/dist/threejs-addon/post-processing/sao-pass.js +296 -0
- package/dist/threejs-addon/post-processing/sao-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/shader-pass.d.ts +11 -0
- package/dist/threejs-addon/post-processing/shader-pass.js +48 -0
- package/dist/threejs-addon/post-processing/shader-pass.js.map +1 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.d.ts +48 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js +290 -0
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js.map +1 -0
- package/dist/threejs-addon/shaders/copy-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/copy-shader.js +39 -0
- package/dist/threejs-addon/shaders/copy-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.d.ts +48 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js +142 -0
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.d.ts +27 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js +56 -0
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/output-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/output-shader.js +72 -0
- package/dist/threejs-addon/shaders/output-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/sao-shader.d.ts +71 -0
- package/dist/threejs-addon/shaders/sao-shader.js +180 -0
- package/dist/threejs-addon/shaders/sao-shader.js.map +1 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.d.ts +13 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js +41 -0
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js.map +1 -0
- package/dist/threejs-addon/simplify-modifier.d.ts +4 -0
- package/dist/threejs-addon/simplify-modifier.js +325 -0
- package/dist/threejs-addon/simplify-modifier.js.map +1 -0
- package/dist/threejs-addon/stats.js +102 -0
- package/dist/threejs-addon/stats.js.map +1 -0
- package/dist/threejs-addon/transform-control.d.ts +74 -0
- package/dist/threejs-addon/transform-control.js +1033 -0
- package/dist/threejs-addon/transform-control.js.map +1 -0
- package/dist/types.d.ts +26 -1
- package/dist/types.js +173 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/html.js +12 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/threejs.js +44 -0
- package/dist/utils/threejs.js.map +1 -0
- package/dist/viral-viewer-api.d.ts +2 -4
- package/dist/viral-viewer-api.js +76 -0
- package/dist/viral-viewer-api.js.map +1 -0
- package/package.json +2 -3
- package/dist/index.mjs +0 -36613
|
@@ -0,0 +1,1265 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
function addCustomMesh3(indices, vertices, material, callback) {
|
|
11
|
+
let verticePoints = [];
|
|
12
|
+
for (let i = 0; i < indices.length; i++) {
|
|
13
|
+
const index = indices[i];
|
|
14
|
+
const point = vertices[index];
|
|
15
|
+
verticePoints.push(-point.X);
|
|
16
|
+
verticePoints.push(point.Z);
|
|
17
|
+
verticePoints.push(point.Y);
|
|
18
|
+
}
|
|
19
|
+
const buffer = new Float32Array(verticePoints);
|
|
20
|
+
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
21
|
+
callback(buffer, colorString, material.Opacity);
|
|
22
|
+
}
|
|
23
|
+
function addCustomMesh4(indices, vertices, material, instances, callback) {
|
|
24
|
+
let colorString = rgbToHex(material.Red, material.Green, material.Blue);
|
|
25
|
+
let finalVerticePoints = [];
|
|
26
|
+
for (let index = 0; index < instances.length; index++) {
|
|
27
|
+
const instance = instances[index];
|
|
28
|
+
let numbers = [
|
|
29
|
+
instance.BasisX.X,
|
|
30
|
+
-instance.BasisX.Z,
|
|
31
|
+
-instance.BasisX.Y,
|
|
32
|
+
0,
|
|
33
|
+
-instance.BasisZ.X,
|
|
34
|
+
instance.BasisZ.Z,
|
|
35
|
+
instance.BasisZ.Y,
|
|
36
|
+
0,
|
|
37
|
+
-instance.BasisY.X,
|
|
38
|
+
instance.BasisY.Z,
|
|
39
|
+
instance.BasisY.Y,
|
|
40
|
+
0,
|
|
41
|
+
-instance.Offset.X,
|
|
42
|
+
instance.Offset.Z,
|
|
43
|
+
instance.Offset.Y,
|
|
44
|
+
1,
|
|
45
|
+
];
|
|
46
|
+
let matrix4 = new Matrix4();
|
|
47
|
+
matrix4.fromArray(numbers);
|
|
48
|
+
let newVertices = [];
|
|
49
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
50
|
+
const point = vertices[i];
|
|
51
|
+
const point2 = new Vector3(-point.X, point.Z, point.Y);
|
|
52
|
+
point2.applyMatrix4(matrix4);
|
|
53
|
+
newVertices.push(point2);
|
|
54
|
+
}
|
|
55
|
+
let verticePoints = [];
|
|
56
|
+
for (let i = 0; i < indices.length; i++) {
|
|
57
|
+
const index = indices[i];
|
|
58
|
+
const point = newVertices[index];
|
|
59
|
+
verticePoints.push(point.x);
|
|
60
|
+
verticePoints.push(point.y);
|
|
61
|
+
verticePoints.push(point.z);
|
|
62
|
+
}
|
|
63
|
+
finalVerticePoints = finalVerticePoints.concat(verticePoints);
|
|
64
|
+
}
|
|
65
|
+
const buffer = new Float32Array(finalVerticePoints);
|
|
66
|
+
callback(buffer, colorString, material.Opacity);
|
|
67
|
+
}
|
|
68
|
+
function progressStructuralGeometries(json, callback) {
|
|
69
|
+
for (let index = 0; index < json.StructuralGeometries.length; index++) {
|
|
70
|
+
const geometry = json.StructuralGeometries[index];
|
|
71
|
+
const material = json.Materials[geometry.MaterialIndex];
|
|
72
|
+
addCustomMesh3(geometry.Indices, geometry.Vertices, material, (buffer, colorString, opacity) => {
|
|
73
|
+
callback(buffer, colorString, opacity);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function progressNoneStructuralGeometries(json, callback) {
|
|
78
|
+
for (let index = 0; index < json.NoneStructuralGeometries.length; index++) {
|
|
79
|
+
const geometry = json.NoneStructuralGeometries[index];
|
|
80
|
+
const material = json.Materials[geometry.MaterialIndex];
|
|
81
|
+
addCustomMesh4(geometry.Indices, geometry.Vertices, material, geometry.Instances, (buffer, colorString, opacity) => {
|
|
82
|
+
callback(buffer, colorString, opacity);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function rgbToHex(r, g, b) {
|
|
87
|
+
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
|
88
|
+
}
|
|
89
|
+
function componentToHex(c) {
|
|
90
|
+
var hex = c.toString(16);
|
|
91
|
+
return hex.length == 1 ? "0" + hex : hex;
|
|
92
|
+
}
|
|
93
|
+
self.addEventListener("message", function (e) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
switch (e.data.type) {
|
|
96
|
+
case 1:
|
|
97
|
+
progressStructuralGeometries(e.data.data, (buffer, colorString, opacity) => {
|
|
98
|
+
self.postMessage({
|
|
99
|
+
type: 1,
|
|
100
|
+
buffer: buffer,
|
|
101
|
+
materialColorString: colorString,
|
|
102
|
+
materialOpacity: opacity,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
progressNoneStructuralGeometries(e.data.data, (buffer, colorString, opacity) => {
|
|
106
|
+
self.postMessage({
|
|
107
|
+
type: 1,
|
|
108
|
+
buffer: buffer,
|
|
109
|
+
materialColorString: colorString,
|
|
110
|
+
materialOpacity: opacity,
|
|
111
|
+
// instances:instances
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
self.postMessage({
|
|
115
|
+
type: 3,
|
|
116
|
+
});
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}, false);
|
|
123
|
+
//#region Declare Type
|
|
124
|
+
class Matrix4 {
|
|
125
|
+
constructor() {
|
|
126
|
+
this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
127
|
+
if (arguments.length > 0) {
|
|
128
|
+
console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
|
|
132
|
+
const te = this.elements;
|
|
133
|
+
te[0] = n11;
|
|
134
|
+
te[4] = n12;
|
|
135
|
+
te[8] = n13;
|
|
136
|
+
te[12] = n14;
|
|
137
|
+
te[1] = n21;
|
|
138
|
+
te[5] = n22;
|
|
139
|
+
te[9] = n23;
|
|
140
|
+
te[13] = n24;
|
|
141
|
+
te[2] = n31;
|
|
142
|
+
te[6] = n32;
|
|
143
|
+
te[10] = n33;
|
|
144
|
+
te[14] = n34;
|
|
145
|
+
te[3] = n41;
|
|
146
|
+
te[7] = n42;
|
|
147
|
+
te[11] = n43;
|
|
148
|
+
te[15] = n44;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
identity() {
|
|
152
|
+
this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
clone() {
|
|
156
|
+
return new Matrix4().fromArray(this.elements);
|
|
157
|
+
}
|
|
158
|
+
copy(m) {
|
|
159
|
+
const te = this.elements;
|
|
160
|
+
const me = m.elements;
|
|
161
|
+
te[0] = me[0];
|
|
162
|
+
te[1] = me[1];
|
|
163
|
+
te[2] = me[2];
|
|
164
|
+
te[3] = me[3];
|
|
165
|
+
te[4] = me[4];
|
|
166
|
+
te[5] = me[5];
|
|
167
|
+
te[6] = me[6];
|
|
168
|
+
te[7] = me[7];
|
|
169
|
+
te[8] = me[8];
|
|
170
|
+
te[9] = me[9];
|
|
171
|
+
te[10] = me[10];
|
|
172
|
+
te[11] = me[11];
|
|
173
|
+
te[12] = me[12];
|
|
174
|
+
te[13] = me[13];
|
|
175
|
+
te[14] = me[14];
|
|
176
|
+
te[15] = me[15];
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
copyPosition(m) {
|
|
180
|
+
const te = this.elements, me = m.elements;
|
|
181
|
+
te[12] = me[12];
|
|
182
|
+
te[13] = me[13];
|
|
183
|
+
te[14] = me[14];
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
setFromMatrix3(m) {
|
|
187
|
+
const me = m.elements;
|
|
188
|
+
this.set(me[0], me[3], me[6], 0, me[1], me[4], me[7], 0, me[2], me[5], me[8], 0, 0, 0, 0, 1);
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
extractBasis(xAxis, yAxis, zAxis) {
|
|
192
|
+
xAxis.setFromMatrixColumn(this, 0);
|
|
193
|
+
yAxis.setFromMatrixColumn(this, 1);
|
|
194
|
+
zAxis.setFromMatrixColumn(this, 2);
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
makeBasis(xAxis, yAxis, zAxis) {
|
|
198
|
+
this.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1);
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
extractRotation(m) {
|
|
202
|
+
// this method does not support reflection matrices
|
|
203
|
+
const te = this.elements;
|
|
204
|
+
const me = m.elements;
|
|
205
|
+
const scaleX = 1 / _v1$5.setFromMatrixColumn(m, 0).length();
|
|
206
|
+
const scaleY = 1 / _v1$5.setFromMatrixColumn(m, 1).length();
|
|
207
|
+
const scaleZ = 1 / _v1$5.setFromMatrixColumn(m, 2).length();
|
|
208
|
+
te[0] = me[0] * scaleX;
|
|
209
|
+
te[1] = me[1] * scaleX;
|
|
210
|
+
te[2] = me[2] * scaleX;
|
|
211
|
+
te[3] = 0;
|
|
212
|
+
te[4] = me[4] * scaleY;
|
|
213
|
+
te[5] = me[5] * scaleY;
|
|
214
|
+
te[6] = me[6] * scaleY;
|
|
215
|
+
te[7] = 0;
|
|
216
|
+
te[8] = me[8] * scaleZ;
|
|
217
|
+
te[9] = me[9] * scaleZ;
|
|
218
|
+
te[10] = me[10] * scaleZ;
|
|
219
|
+
te[11] = 0;
|
|
220
|
+
te[12] = 0;
|
|
221
|
+
te[13] = 0;
|
|
222
|
+
te[14] = 0;
|
|
223
|
+
te[15] = 1;
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
makeRotationFromEuler(euler) {
|
|
227
|
+
if (!(euler && euler.isEuler)) {
|
|
228
|
+
console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
|
|
229
|
+
}
|
|
230
|
+
const te = this.elements;
|
|
231
|
+
const x = euler.x, y = euler.y, z = euler.z;
|
|
232
|
+
const a = Math.cos(x), b = Math.sin(x);
|
|
233
|
+
const c = Math.cos(y), d = Math.sin(y);
|
|
234
|
+
const e = Math.cos(z), f = Math.sin(z);
|
|
235
|
+
if (euler.order === "XYZ") {
|
|
236
|
+
const ae = a * e, af = a * f, be = b * e, bf = b * f;
|
|
237
|
+
te[0] = c * e;
|
|
238
|
+
te[4] = -c * f;
|
|
239
|
+
te[8] = d;
|
|
240
|
+
te[1] = af + be * d;
|
|
241
|
+
te[5] = ae - bf * d;
|
|
242
|
+
te[9] = -b * c;
|
|
243
|
+
te[2] = bf - ae * d;
|
|
244
|
+
te[6] = be + af * d;
|
|
245
|
+
te[10] = a * c;
|
|
246
|
+
}
|
|
247
|
+
else if (euler.order === "YXZ") {
|
|
248
|
+
const ce = c * e, cf = c * f, de = d * e, df = d * f;
|
|
249
|
+
te[0] = ce + df * b;
|
|
250
|
+
te[4] = de * b - cf;
|
|
251
|
+
te[8] = a * d;
|
|
252
|
+
te[1] = a * f;
|
|
253
|
+
te[5] = a * e;
|
|
254
|
+
te[9] = -b;
|
|
255
|
+
te[2] = cf * b - de;
|
|
256
|
+
te[6] = df + ce * b;
|
|
257
|
+
te[10] = a * c;
|
|
258
|
+
}
|
|
259
|
+
else if (euler.order === "ZXY") {
|
|
260
|
+
const ce = c * e, cf = c * f, de = d * e, df = d * f;
|
|
261
|
+
te[0] = ce - df * b;
|
|
262
|
+
te[4] = -a * f;
|
|
263
|
+
te[8] = de + cf * b;
|
|
264
|
+
te[1] = cf + de * b;
|
|
265
|
+
te[5] = a * e;
|
|
266
|
+
te[9] = df - ce * b;
|
|
267
|
+
te[2] = -a * d;
|
|
268
|
+
te[6] = b;
|
|
269
|
+
te[10] = a * c;
|
|
270
|
+
}
|
|
271
|
+
else if (euler.order === "ZYX") {
|
|
272
|
+
const ae = a * e, af = a * f, be = b * e, bf = b * f;
|
|
273
|
+
te[0] = c * e;
|
|
274
|
+
te[4] = be * d - af;
|
|
275
|
+
te[8] = ae * d + bf;
|
|
276
|
+
te[1] = c * f;
|
|
277
|
+
te[5] = bf * d + ae;
|
|
278
|
+
te[9] = af * d - be;
|
|
279
|
+
te[2] = -d;
|
|
280
|
+
te[6] = b * c;
|
|
281
|
+
te[10] = a * c;
|
|
282
|
+
}
|
|
283
|
+
else if (euler.order === "YZX") {
|
|
284
|
+
const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
|
|
285
|
+
te[0] = c * e;
|
|
286
|
+
te[4] = bd - ac * f;
|
|
287
|
+
te[8] = bc * f + ad;
|
|
288
|
+
te[1] = f;
|
|
289
|
+
te[5] = a * e;
|
|
290
|
+
te[9] = -b * e;
|
|
291
|
+
te[2] = -d * e;
|
|
292
|
+
te[6] = ad * f + bc;
|
|
293
|
+
te[10] = ac - bd * f;
|
|
294
|
+
}
|
|
295
|
+
else if (euler.order === "XZY") {
|
|
296
|
+
const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
|
|
297
|
+
te[0] = c * e;
|
|
298
|
+
te[4] = -f;
|
|
299
|
+
te[8] = d * e;
|
|
300
|
+
te[1] = ac * f + bd;
|
|
301
|
+
te[5] = a * e;
|
|
302
|
+
te[9] = ad * f - bc;
|
|
303
|
+
te[2] = bc * f - ad;
|
|
304
|
+
te[6] = b * e;
|
|
305
|
+
te[10] = bd * f + ac;
|
|
306
|
+
}
|
|
307
|
+
// bottom row
|
|
308
|
+
te[3] = 0;
|
|
309
|
+
te[7] = 0;
|
|
310
|
+
te[11] = 0;
|
|
311
|
+
// last column
|
|
312
|
+
te[12] = 0;
|
|
313
|
+
te[13] = 0;
|
|
314
|
+
te[14] = 0;
|
|
315
|
+
te[15] = 1;
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
318
|
+
makeRotationFromQuaternion(q) {
|
|
319
|
+
return this.compose(_zero, q, _one);
|
|
320
|
+
}
|
|
321
|
+
lookAt(eye, target, up) {
|
|
322
|
+
const te = this.elements;
|
|
323
|
+
_z.subVectors(eye, target);
|
|
324
|
+
if (_z.lengthSq() === 0) {
|
|
325
|
+
// eye and target are in the same position
|
|
326
|
+
_z.z = 1;
|
|
327
|
+
}
|
|
328
|
+
_z.normalize();
|
|
329
|
+
_x.crossVectors(up, _z);
|
|
330
|
+
if (_x.lengthSq() === 0) {
|
|
331
|
+
// up and z are parallel
|
|
332
|
+
if (Math.abs(up.z) === 1) {
|
|
333
|
+
_z.x += 0.0001;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
_z.z += 0.0001;
|
|
337
|
+
}
|
|
338
|
+
_z.normalize();
|
|
339
|
+
_x.crossVectors(up, _z);
|
|
340
|
+
}
|
|
341
|
+
_x.normalize();
|
|
342
|
+
_y.crossVectors(_z, _x);
|
|
343
|
+
te[0] = _x.x;
|
|
344
|
+
te[4] = _y.x;
|
|
345
|
+
te[8] = _z.x;
|
|
346
|
+
te[1] = _x.y;
|
|
347
|
+
te[5] = _y.y;
|
|
348
|
+
te[9] = _z.y;
|
|
349
|
+
te[2] = _x.z;
|
|
350
|
+
te[6] = _y.z;
|
|
351
|
+
te[10] = _z.z;
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
multiply(m, n) {
|
|
355
|
+
if (n !== undefined) {
|
|
356
|
+
console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.");
|
|
357
|
+
return this.multiplyMatrices(m, n);
|
|
358
|
+
}
|
|
359
|
+
return this.multiplyMatrices(this, m);
|
|
360
|
+
}
|
|
361
|
+
premultiply(m) {
|
|
362
|
+
return this.multiplyMatrices(m, this);
|
|
363
|
+
}
|
|
364
|
+
multiplyMatrices(a, b) {
|
|
365
|
+
const ae = a.elements;
|
|
366
|
+
const be = b.elements;
|
|
367
|
+
const te = this.elements;
|
|
368
|
+
const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
|
|
369
|
+
const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
|
|
370
|
+
const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
|
|
371
|
+
const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
|
|
372
|
+
const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
|
|
373
|
+
const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
|
|
374
|
+
const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
|
|
375
|
+
const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
|
|
376
|
+
te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
|
|
377
|
+
te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
|
|
378
|
+
te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
|
|
379
|
+
te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
|
|
380
|
+
te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
|
|
381
|
+
te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
|
|
382
|
+
te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
|
|
383
|
+
te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
|
|
384
|
+
te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
|
|
385
|
+
te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
|
|
386
|
+
te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
|
|
387
|
+
te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
|
|
388
|
+
te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
|
|
389
|
+
te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
|
|
390
|
+
te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
|
|
391
|
+
te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
|
|
392
|
+
return this;
|
|
393
|
+
}
|
|
394
|
+
multiplyScalar(s) {
|
|
395
|
+
const te = this.elements;
|
|
396
|
+
te[0] *= s;
|
|
397
|
+
te[4] *= s;
|
|
398
|
+
te[8] *= s;
|
|
399
|
+
te[12] *= s;
|
|
400
|
+
te[1] *= s;
|
|
401
|
+
te[5] *= s;
|
|
402
|
+
te[9] *= s;
|
|
403
|
+
te[13] *= s;
|
|
404
|
+
te[2] *= s;
|
|
405
|
+
te[6] *= s;
|
|
406
|
+
te[10] *= s;
|
|
407
|
+
te[14] *= s;
|
|
408
|
+
te[3] *= s;
|
|
409
|
+
te[7] *= s;
|
|
410
|
+
te[11] *= s;
|
|
411
|
+
te[15] *= s;
|
|
412
|
+
return this;
|
|
413
|
+
}
|
|
414
|
+
determinant() {
|
|
415
|
+
const te = this.elements;
|
|
416
|
+
const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
|
|
417
|
+
const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
|
|
418
|
+
const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
|
|
419
|
+
const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
|
|
420
|
+
//TODO: make this more efficient
|
|
421
|
+
//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
|
|
422
|
+
return (n41 *
|
|
423
|
+
(+n14 * n23 * n32 -
|
|
424
|
+
n13 * n24 * n32 -
|
|
425
|
+
n14 * n22 * n33 +
|
|
426
|
+
n12 * n24 * n33 +
|
|
427
|
+
n13 * n22 * n34 -
|
|
428
|
+
n12 * n23 * n34) +
|
|
429
|
+
n42 *
|
|
430
|
+
(+n11 * n23 * n34 -
|
|
431
|
+
n11 * n24 * n33 +
|
|
432
|
+
n14 * n21 * n33 -
|
|
433
|
+
n13 * n21 * n34 +
|
|
434
|
+
n13 * n24 * n31 -
|
|
435
|
+
n14 * n23 * n31) +
|
|
436
|
+
n43 *
|
|
437
|
+
(+n11 * n24 * n32 -
|
|
438
|
+
n11 * n22 * n34 -
|
|
439
|
+
n14 * n21 * n32 +
|
|
440
|
+
n12 * n21 * n34 +
|
|
441
|
+
n14 * n22 * n31 -
|
|
442
|
+
n12 * n24 * n31) +
|
|
443
|
+
n44 *
|
|
444
|
+
(-n13 * n22 * n31 -
|
|
445
|
+
n11 * n23 * n32 +
|
|
446
|
+
n11 * n22 * n33 +
|
|
447
|
+
n13 * n21 * n32 -
|
|
448
|
+
n12 * n21 * n33 +
|
|
449
|
+
n12 * n23 * n31));
|
|
450
|
+
}
|
|
451
|
+
transpose() {
|
|
452
|
+
const te = this.elements;
|
|
453
|
+
let tmp;
|
|
454
|
+
tmp = te[1];
|
|
455
|
+
te[1] = te[4];
|
|
456
|
+
te[4] = tmp;
|
|
457
|
+
tmp = te[2];
|
|
458
|
+
te[2] = te[8];
|
|
459
|
+
te[8] = tmp;
|
|
460
|
+
tmp = te[6];
|
|
461
|
+
te[6] = te[9];
|
|
462
|
+
te[9] = tmp;
|
|
463
|
+
tmp = te[3];
|
|
464
|
+
te[3] = te[12];
|
|
465
|
+
te[12] = tmp;
|
|
466
|
+
tmp = te[7];
|
|
467
|
+
te[7] = te[13];
|
|
468
|
+
te[13] = tmp;
|
|
469
|
+
tmp = te[11];
|
|
470
|
+
te[11] = te[14];
|
|
471
|
+
te[14] = tmp;
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
setPosition(x, y, z) {
|
|
475
|
+
const te = this.elements;
|
|
476
|
+
if (x.isVector3) {
|
|
477
|
+
te[12] = x.x;
|
|
478
|
+
te[13] = x.y;
|
|
479
|
+
te[14] = x.z;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
te[12] = x;
|
|
483
|
+
te[13] = y;
|
|
484
|
+
te[14] = z;
|
|
485
|
+
}
|
|
486
|
+
return this;
|
|
487
|
+
}
|
|
488
|
+
invert() {
|
|
489
|
+
// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
|
|
490
|
+
const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 -
|
|
491
|
+
n24 * n33 * n42 +
|
|
492
|
+
n24 * n32 * n43 -
|
|
493
|
+
n22 * n34 * n43 -
|
|
494
|
+
n23 * n32 * n44 +
|
|
495
|
+
n22 * n33 * n44, t12 = n14 * n33 * n42 -
|
|
496
|
+
n13 * n34 * n42 -
|
|
497
|
+
n14 * n32 * n43 +
|
|
498
|
+
n12 * n34 * n43 +
|
|
499
|
+
n13 * n32 * n44 -
|
|
500
|
+
n12 * n33 * n44, t13 = n13 * n24 * n42 -
|
|
501
|
+
n14 * n23 * n42 +
|
|
502
|
+
n14 * n22 * n43 -
|
|
503
|
+
n12 * n24 * n43 -
|
|
504
|
+
n13 * n22 * n44 +
|
|
505
|
+
n12 * n23 * n44, t14 = n14 * n23 * n32 -
|
|
506
|
+
n13 * n24 * n32 -
|
|
507
|
+
n14 * n22 * n33 +
|
|
508
|
+
n12 * n24 * n33 +
|
|
509
|
+
n13 * n22 * n34 -
|
|
510
|
+
n12 * n23 * n34;
|
|
511
|
+
const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
512
|
+
if (det === 0)
|
|
513
|
+
return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
514
|
+
const detInv = 1 / det;
|
|
515
|
+
te[0] = t11 * detInv;
|
|
516
|
+
te[1] =
|
|
517
|
+
(n24 * n33 * n41 -
|
|
518
|
+
n23 * n34 * n41 -
|
|
519
|
+
n24 * n31 * n43 +
|
|
520
|
+
n21 * n34 * n43 +
|
|
521
|
+
n23 * n31 * n44 -
|
|
522
|
+
n21 * n33 * n44) *
|
|
523
|
+
detInv;
|
|
524
|
+
te[2] =
|
|
525
|
+
(n22 * n34 * n41 -
|
|
526
|
+
n24 * n32 * n41 +
|
|
527
|
+
n24 * n31 * n42 -
|
|
528
|
+
n21 * n34 * n42 -
|
|
529
|
+
n22 * n31 * n44 +
|
|
530
|
+
n21 * n32 * n44) *
|
|
531
|
+
detInv;
|
|
532
|
+
te[3] =
|
|
533
|
+
(n23 * n32 * n41 -
|
|
534
|
+
n22 * n33 * n41 -
|
|
535
|
+
n23 * n31 * n42 +
|
|
536
|
+
n21 * n33 * n42 +
|
|
537
|
+
n22 * n31 * n43 -
|
|
538
|
+
n21 * n32 * n43) *
|
|
539
|
+
detInv;
|
|
540
|
+
te[4] = t12 * detInv;
|
|
541
|
+
te[5] =
|
|
542
|
+
(n13 * n34 * n41 -
|
|
543
|
+
n14 * n33 * n41 +
|
|
544
|
+
n14 * n31 * n43 -
|
|
545
|
+
n11 * n34 * n43 -
|
|
546
|
+
n13 * n31 * n44 +
|
|
547
|
+
n11 * n33 * n44) *
|
|
548
|
+
detInv;
|
|
549
|
+
te[6] =
|
|
550
|
+
(n14 * n32 * n41 -
|
|
551
|
+
n12 * n34 * n41 -
|
|
552
|
+
n14 * n31 * n42 +
|
|
553
|
+
n11 * n34 * n42 +
|
|
554
|
+
n12 * n31 * n44 -
|
|
555
|
+
n11 * n32 * n44) *
|
|
556
|
+
detInv;
|
|
557
|
+
te[7] =
|
|
558
|
+
(n12 * n33 * n41 -
|
|
559
|
+
n13 * n32 * n41 +
|
|
560
|
+
n13 * n31 * n42 -
|
|
561
|
+
n11 * n33 * n42 -
|
|
562
|
+
n12 * n31 * n43 +
|
|
563
|
+
n11 * n32 * n43) *
|
|
564
|
+
detInv;
|
|
565
|
+
te[8] = t13 * detInv;
|
|
566
|
+
te[9] =
|
|
567
|
+
(n14 * n23 * n41 -
|
|
568
|
+
n13 * n24 * n41 -
|
|
569
|
+
n14 * n21 * n43 +
|
|
570
|
+
n11 * n24 * n43 +
|
|
571
|
+
n13 * n21 * n44 -
|
|
572
|
+
n11 * n23 * n44) *
|
|
573
|
+
detInv;
|
|
574
|
+
te[10] =
|
|
575
|
+
(n12 * n24 * n41 -
|
|
576
|
+
n14 * n22 * n41 +
|
|
577
|
+
n14 * n21 * n42 -
|
|
578
|
+
n11 * n24 * n42 -
|
|
579
|
+
n12 * n21 * n44 +
|
|
580
|
+
n11 * n22 * n44) *
|
|
581
|
+
detInv;
|
|
582
|
+
te[11] =
|
|
583
|
+
(n13 * n22 * n41 -
|
|
584
|
+
n12 * n23 * n41 -
|
|
585
|
+
n13 * n21 * n42 +
|
|
586
|
+
n11 * n23 * n42 +
|
|
587
|
+
n12 * n21 * n43 -
|
|
588
|
+
n11 * n22 * n43) *
|
|
589
|
+
detInv;
|
|
590
|
+
te[12] = t14 * detInv;
|
|
591
|
+
te[13] =
|
|
592
|
+
(n13 * n24 * n31 -
|
|
593
|
+
n14 * n23 * n31 +
|
|
594
|
+
n14 * n21 * n33 -
|
|
595
|
+
n11 * n24 * n33 -
|
|
596
|
+
n13 * n21 * n34 +
|
|
597
|
+
n11 * n23 * n34) *
|
|
598
|
+
detInv;
|
|
599
|
+
te[14] =
|
|
600
|
+
(n14 * n22 * n31 -
|
|
601
|
+
n12 * n24 * n31 -
|
|
602
|
+
n14 * n21 * n32 +
|
|
603
|
+
n11 * n24 * n32 +
|
|
604
|
+
n12 * n21 * n34 -
|
|
605
|
+
n11 * n22 * n34) *
|
|
606
|
+
detInv;
|
|
607
|
+
te[15] =
|
|
608
|
+
(n12 * n23 * n31 -
|
|
609
|
+
n13 * n22 * n31 +
|
|
610
|
+
n13 * n21 * n32 -
|
|
611
|
+
n11 * n23 * n32 -
|
|
612
|
+
n12 * n21 * n33 +
|
|
613
|
+
n11 * n22 * n33) *
|
|
614
|
+
detInv;
|
|
615
|
+
return this;
|
|
616
|
+
}
|
|
617
|
+
scale(v) {
|
|
618
|
+
const te = this.elements;
|
|
619
|
+
const x = v.x, y = v.y, z = v.z;
|
|
620
|
+
te[0] *= x;
|
|
621
|
+
te[4] *= y;
|
|
622
|
+
te[8] *= z;
|
|
623
|
+
te[1] *= x;
|
|
624
|
+
te[5] *= y;
|
|
625
|
+
te[9] *= z;
|
|
626
|
+
te[2] *= x;
|
|
627
|
+
te[6] *= y;
|
|
628
|
+
te[10] *= z;
|
|
629
|
+
te[3] *= x;
|
|
630
|
+
te[7] *= y;
|
|
631
|
+
te[11] *= z;
|
|
632
|
+
return this;
|
|
633
|
+
}
|
|
634
|
+
getMaxScaleOnAxis() {
|
|
635
|
+
const te = this.elements;
|
|
636
|
+
const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
|
|
637
|
+
const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
|
|
638
|
+
const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
|
|
639
|
+
return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
|
|
640
|
+
}
|
|
641
|
+
makeTranslation(x, y, z) {
|
|
642
|
+
this.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
makeRotationX(theta) {
|
|
646
|
+
const c = Math.cos(theta), s = Math.sin(theta);
|
|
647
|
+
this.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
makeRotationY(theta) {
|
|
651
|
+
const c = Math.cos(theta), s = Math.sin(theta);
|
|
652
|
+
this.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
|
|
653
|
+
return this;
|
|
654
|
+
}
|
|
655
|
+
makeRotationZ(theta) {
|
|
656
|
+
const c = Math.cos(theta), s = Math.sin(theta);
|
|
657
|
+
this.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
makeRotationAxis(axis, angle) {
|
|
661
|
+
// Based on http://www.gamedev.net/reference/articles/article1199.asp
|
|
662
|
+
const c = Math.cos(angle);
|
|
663
|
+
const s = Math.sin(angle);
|
|
664
|
+
const t = 1 - c;
|
|
665
|
+
const x = axis.x, y = axis.y, z = axis.z;
|
|
666
|
+
const tx = t * x, ty = t * y;
|
|
667
|
+
this.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
makeScale(x, y, z) {
|
|
671
|
+
this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
makeShear(xy, xz, yx, yz, zx, zy) {
|
|
675
|
+
this.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1);
|
|
676
|
+
return this;
|
|
677
|
+
}
|
|
678
|
+
compose(position, quaternion, scale) {
|
|
679
|
+
const te = this.elements;
|
|
680
|
+
const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
|
|
681
|
+
const x2 = x + x, y2 = y + y, z2 = z + z;
|
|
682
|
+
const xx = x * x2, xy = x * y2, xz = x * z2;
|
|
683
|
+
const yy = y * y2, yz = y * z2, zz = z * z2;
|
|
684
|
+
const wx = w * x2, wy = w * y2, wz = w * z2;
|
|
685
|
+
const sx = scale.x, sy = scale.y, sz = scale.z;
|
|
686
|
+
te[0] = (1 - (yy + zz)) * sx;
|
|
687
|
+
te[1] = (xy + wz) * sx;
|
|
688
|
+
te[2] = (xz - wy) * sx;
|
|
689
|
+
te[3] = 0;
|
|
690
|
+
te[4] = (xy - wz) * sy;
|
|
691
|
+
te[5] = (1 - (xx + zz)) * sy;
|
|
692
|
+
te[6] = (yz + wx) * sy;
|
|
693
|
+
te[7] = 0;
|
|
694
|
+
te[8] = (xz + wy) * sz;
|
|
695
|
+
te[9] = (yz - wx) * sz;
|
|
696
|
+
te[10] = (1 - (xx + yy)) * sz;
|
|
697
|
+
te[11] = 0;
|
|
698
|
+
te[12] = position.x;
|
|
699
|
+
te[13] = position.y;
|
|
700
|
+
te[14] = position.z;
|
|
701
|
+
te[15] = 1;
|
|
702
|
+
return this;
|
|
703
|
+
}
|
|
704
|
+
decompose(position, quaternion, scale) {
|
|
705
|
+
const te = this.elements;
|
|
706
|
+
let sx = _v1$5.set(te[0], te[1], te[2]).length();
|
|
707
|
+
const sy = _v1$5.set(te[4], te[5], te[6]).length();
|
|
708
|
+
const sz = _v1$5.set(te[8], te[9], te[10]).length();
|
|
709
|
+
// if determine is negative, we need to invert one scale
|
|
710
|
+
const det = this.determinant();
|
|
711
|
+
if (det < 0)
|
|
712
|
+
sx = -sx;
|
|
713
|
+
position.x = te[12];
|
|
714
|
+
position.y = te[13];
|
|
715
|
+
position.z = te[14];
|
|
716
|
+
// scale the rotation part
|
|
717
|
+
_m1$2.copy(this);
|
|
718
|
+
const invSX = 1 / sx;
|
|
719
|
+
const invSY = 1 / sy;
|
|
720
|
+
const invSZ = 1 / sz;
|
|
721
|
+
_m1$2.elements[0] *= invSX;
|
|
722
|
+
_m1$2.elements[1] *= invSX;
|
|
723
|
+
_m1$2.elements[2] *= invSX;
|
|
724
|
+
_m1$2.elements[4] *= invSY;
|
|
725
|
+
_m1$2.elements[5] *= invSY;
|
|
726
|
+
_m1$2.elements[6] *= invSY;
|
|
727
|
+
_m1$2.elements[8] *= invSZ;
|
|
728
|
+
_m1$2.elements[9] *= invSZ;
|
|
729
|
+
_m1$2.elements[10] *= invSZ;
|
|
730
|
+
quaternion.setFromRotationMatrix(_m1$2);
|
|
731
|
+
scale.x = sx;
|
|
732
|
+
scale.y = sy;
|
|
733
|
+
scale.z = sz;
|
|
734
|
+
return this;
|
|
735
|
+
}
|
|
736
|
+
makePerspective(left, right, top, bottom, near, far) {
|
|
737
|
+
if (far === undefined) {
|
|
738
|
+
console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
|
|
739
|
+
}
|
|
740
|
+
const te = this.elements;
|
|
741
|
+
const x = (2 * near) / (right - left);
|
|
742
|
+
const y = (2 * near) / (top - bottom);
|
|
743
|
+
const a = (right + left) / (right - left);
|
|
744
|
+
const b = (top + bottom) / (top - bottom);
|
|
745
|
+
const c = -(far + near) / (far - near);
|
|
746
|
+
const d = (-2 * far * near) / (far - near);
|
|
747
|
+
te[0] = x;
|
|
748
|
+
te[4] = 0;
|
|
749
|
+
te[8] = a;
|
|
750
|
+
te[12] = 0;
|
|
751
|
+
te[1] = 0;
|
|
752
|
+
te[5] = y;
|
|
753
|
+
te[9] = b;
|
|
754
|
+
te[13] = 0;
|
|
755
|
+
te[2] = 0;
|
|
756
|
+
te[6] = 0;
|
|
757
|
+
te[10] = c;
|
|
758
|
+
te[14] = d;
|
|
759
|
+
te[3] = 0;
|
|
760
|
+
te[7] = 0;
|
|
761
|
+
te[11] = -1;
|
|
762
|
+
te[15] = 0;
|
|
763
|
+
return this;
|
|
764
|
+
}
|
|
765
|
+
makeOrthographic(left, right, top, bottom, near, far) {
|
|
766
|
+
const te = this.elements;
|
|
767
|
+
const w = 1.0 / (right - left);
|
|
768
|
+
const h = 1.0 / (top - bottom);
|
|
769
|
+
const p = 1.0 / (far - near);
|
|
770
|
+
const x = (right + left) * w;
|
|
771
|
+
const y = (top + bottom) * h;
|
|
772
|
+
const z = (far + near) * p;
|
|
773
|
+
te[0] = 2 * w;
|
|
774
|
+
te[4] = 0;
|
|
775
|
+
te[8] = 0;
|
|
776
|
+
te[12] = -x;
|
|
777
|
+
te[1] = 0;
|
|
778
|
+
te[5] = 2 * h;
|
|
779
|
+
te[9] = 0;
|
|
780
|
+
te[13] = -y;
|
|
781
|
+
te[2] = 0;
|
|
782
|
+
te[6] = 0;
|
|
783
|
+
te[10] = -2 * p;
|
|
784
|
+
te[14] = -z;
|
|
785
|
+
te[3] = 0;
|
|
786
|
+
te[7] = 0;
|
|
787
|
+
te[11] = 0;
|
|
788
|
+
te[15] = 1;
|
|
789
|
+
return this;
|
|
790
|
+
}
|
|
791
|
+
equals(matrix) {
|
|
792
|
+
const te = this.elements;
|
|
793
|
+
const me = matrix.elements;
|
|
794
|
+
for (let i = 0; i < 16; i++) {
|
|
795
|
+
if (te[i] !== me[i])
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
fromArray(array, offset = 0) {
|
|
801
|
+
for (let i = 0; i < 16; i++) {
|
|
802
|
+
this.elements[i] = array[i + offset];
|
|
803
|
+
}
|
|
804
|
+
return this;
|
|
805
|
+
}
|
|
806
|
+
toArray(array = [], offset = 0) {
|
|
807
|
+
const te = this.elements;
|
|
808
|
+
array[offset] = te[0];
|
|
809
|
+
array[offset + 1] = te[1];
|
|
810
|
+
array[offset + 2] = te[2];
|
|
811
|
+
array[offset + 3] = te[3];
|
|
812
|
+
array[offset + 4] = te[4];
|
|
813
|
+
array[offset + 5] = te[5];
|
|
814
|
+
array[offset + 6] = te[6];
|
|
815
|
+
array[offset + 7] = te[7];
|
|
816
|
+
array[offset + 8] = te[8];
|
|
817
|
+
array[offset + 9] = te[9];
|
|
818
|
+
array[offset + 10] = te[10];
|
|
819
|
+
array[offset + 11] = te[11];
|
|
820
|
+
array[offset + 12] = te[12];
|
|
821
|
+
array[offset + 13] = te[13];
|
|
822
|
+
array[offset + 14] = te[14];
|
|
823
|
+
array[offset + 15] = te[15];
|
|
824
|
+
return array;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
Matrix4.prototype.isMatrix4 = true;
|
|
828
|
+
class Vector3 {
|
|
829
|
+
constructor(x = 0, y = 0, z = 0) {
|
|
830
|
+
this.x = x;
|
|
831
|
+
this.y = y;
|
|
832
|
+
this.z = z;
|
|
833
|
+
}
|
|
834
|
+
set(x, y, z) {
|
|
835
|
+
if (z === undefined)
|
|
836
|
+
z = this.z; // sprite.scale.set(x,y)
|
|
837
|
+
this.x = x;
|
|
838
|
+
this.y = y;
|
|
839
|
+
this.z = z;
|
|
840
|
+
return this;
|
|
841
|
+
}
|
|
842
|
+
setScalar(scalar) {
|
|
843
|
+
this.x = scalar;
|
|
844
|
+
this.y = scalar;
|
|
845
|
+
this.z = scalar;
|
|
846
|
+
return this;
|
|
847
|
+
}
|
|
848
|
+
setX(x) {
|
|
849
|
+
this.x = x;
|
|
850
|
+
return this;
|
|
851
|
+
}
|
|
852
|
+
setY(y) {
|
|
853
|
+
this.y = y;
|
|
854
|
+
return this;
|
|
855
|
+
}
|
|
856
|
+
setZ(z) {
|
|
857
|
+
this.z = z;
|
|
858
|
+
return this;
|
|
859
|
+
}
|
|
860
|
+
setComponent(index, value) {
|
|
861
|
+
switch (index) {
|
|
862
|
+
case 0:
|
|
863
|
+
this.x = value;
|
|
864
|
+
break;
|
|
865
|
+
case 1:
|
|
866
|
+
this.y = value;
|
|
867
|
+
break;
|
|
868
|
+
case 2:
|
|
869
|
+
this.z = value;
|
|
870
|
+
break;
|
|
871
|
+
default:
|
|
872
|
+
throw new Error("index is out of range: " + index);
|
|
873
|
+
}
|
|
874
|
+
return this;
|
|
875
|
+
}
|
|
876
|
+
getComponent(index) {
|
|
877
|
+
switch (index) {
|
|
878
|
+
case 0:
|
|
879
|
+
return this.x;
|
|
880
|
+
case 1:
|
|
881
|
+
return this.y;
|
|
882
|
+
case 2:
|
|
883
|
+
return this.z;
|
|
884
|
+
default:
|
|
885
|
+
throw new Error("index is out of range: " + index);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
clone() {
|
|
889
|
+
return new this.constructor(this.x, this.y, this.z);
|
|
890
|
+
}
|
|
891
|
+
copy(v) {
|
|
892
|
+
this.x = v.x;
|
|
893
|
+
this.y = v.y;
|
|
894
|
+
this.z = v.z;
|
|
895
|
+
return this;
|
|
896
|
+
}
|
|
897
|
+
add(v, w) {
|
|
898
|
+
if (w !== undefined) {
|
|
899
|
+
console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.");
|
|
900
|
+
return this.addVectors(v, w);
|
|
901
|
+
}
|
|
902
|
+
this.x += v.x;
|
|
903
|
+
this.y += v.y;
|
|
904
|
+
this.z += v.z;
|
|
905
|
+
return this;
|
|
906
|
+
}
|
|
907
|
+
addScalar(s) {
|
|
908
|
+
this.x += s;
|
|
909
|
+
this.y += s;
|
|
910
|
+
this.z += s;
|
|
911
|
+
return this;
|
|
912
|
+
}
|
|
913
|
+
addVectors(a, b) {
|
|
914
|
+
this.x = a.x + b.x;
|
|
915
|
+
this.y = a.y + b.y;
|
|
916
|
+
this.z = a.z + b.z;
|
|
917
|
+
return this;
|
|
918
|
+
}
|
|
919
|
+
addScaledVector(v, s) {
|
|
920
|
+
this.x += v.x * s;
|
|
921
|
+
this.y += v.y * s;
|
|
922
|
+
this.z += v.z * s;
|
|
923
|
+
return this;
|
|
924
|
+
}
|
|
925
|
+
sub(v, w) {
|
|
926
|
+
if (w !== undefined) {
|
|
927
|
+
console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");
|
|
928
|
+
return this.subVectors(v, w);
|
|
929
|
+
}
|
|
930
|
+
this.x -= v.x;
|
|
931
|
+
this.y -= v.y;
|
|
932
|
+
this.z -= v.z;
|
|
933
|
+
return this;
|
|
934
|
+
}
|
|
935
|
+
subScalar(s) {
|
|
936
|
+
this.x -= s;
|
|
937
|
+
this.y -= s;
|
|
938
|
+
this.z -= s;
|
|
939
|
+
return this;
|
|
940
|
+
}
|
|
941
|
+
subVectors(a, b) {
|
|
942
|
+
this.x = a.x - b.x;
|
|
943
|
+
this.y = a.y - b.y;
|
|
944
|
+
this.z = a.z - b.z;
|
|
945
|
+
return this;
|
|
946
|
+
}
|
|
947
|
+
multiply(v, w) {
|
|
948
|
+
if (w !== undefined) {
|
|
949
|
+
console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.");
|
|
950
|
+
return this.multiplyVectors(v, w);
|
|
951
|
+
}
|
|
952
|
+
this.x *= v.x;
|
|
953
|
+
this.y *= v.y;
|
|
954
|
+
this.z *= v.z;
|
|
955
|
+
return this;
|
|
956
|
+
}
|
|
957
|
+
multiplyScalar(scalar) {
|
|
958
|
+
this.x *= scalar;
|
|
959
|
+
this.y *= scalar;
|
|
960
|
+
this.z *= scalar;
|
|
961
|
+
return this;
|
|
962
|
+
}
|
|
963
|
+
multiplyVectors(a, b) {
|
|
964
|
+
this.x = a.x * b.x;
|
|
965
|
+
this.y = a.y * b.y;
|
|
966
|
+
this.z = a.z * b.z;
|
|
967
|
+
return this;
|
|
968
|
+
}
|
|
969
|
+
applyEuler(euler) {
|
|
970
|
+
if (!(euler && euler.isEuler)) {
|
|
971
|
+
console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");
|
|
972
|
+
}
|
|
973
|
+
return this.applyQuaternion(_quaternion$4.setFromEuler(euler));
|
|
974
|
+
}
|
|
975
|
+
applyAxisAngle(axis, angle) {
|
|
976
|
+
return this.applyQuaternion(_quaternion$4.setFromAxisAngle(axis, angle));
|
|
977
|
+
}
|
|
978
|
+
applyMatrix3(m) {
|
|
979
|
+
const x = this.x, y = this.y, z = this.z;
|
|
980
|
+
const e = m.elements;
|
|
981
|
+
this.x = e[0] * x + e[3] * y + e[6] * z;
|
|
982
|
+
this.y = e[1] * x + e[4] * y + e[7] * z;
|
|
983
|
+
this.z = e[2] * x + e[5] * y + e[8] * z;
|
|
984
|
+
return this;
|
|
985
|
+
}
|
|
986
|
+
applyNormalMatrix(m) {
|
|
987
|
+
return this.applyMatrix3(m).normalize();
|
|
988
|
+
}
|
|
989
|
+
applyMatrix4(m) {
|
|
990
|
+
const x = this.x, y = this.y, z = this.z;
|
|
991
|
+
const e = m.elements;
|
|
992
|
+
const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
|
993
|
+
this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
|
|
994
|
+
this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
|
|
995
|
+
this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
|
|
996
|
+
return this;
|
|
997
|
+
}
|
|
998
|
+
applyQuaternion(q) {
|
|
999
|
+
const x = this.x, y = this.y, z = this.z;
|
|
1000
|
+
const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
|
|
1001
|
+
// calculate quat * vector
|
|
1002
|
+
const ix = qw * x + qy * z - qz * y;
|
|
1003
|
+
const iy = qw * y + qz * x - qx * z;
|
|
1004
|
+
const iz = qw * z + qx * y - qy * x;
|
|
1005
|
+
const iw = -qx * x - qy * y - qz * z;
|
|
1006
|
+
// calculate result * inverse quat
|
|
1007
|
+
this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
1008
|
+
this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
1009
|
+
this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
1010
|
+
return this;
|
|
1011
|
+
}
|
|
1012
|
+
project(camera) {
|
|
1013
|
+
return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
|
|
1014
|
+
}
|
|
1015
|
+
unproject(camera) {
|
|
1016
|
+
return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
|
|
1017
|
+
}
|
|
1018
|
+
transformDirection(m) {
|
|
1019
|
+
// input: THREE.Matrix4 affine matrix
|
|
1020
|
+
// vector interpreted as a direction
|
|
1021
|
+
const x = this.x, y = this.y, z = this.z;
|
|
1022
|
+
const e = m.elements;
|
|
1023
|
+
this.x = e[0] * x + e[4] * y + e[8] * z;
|
|
1024
|
+
this.y = e[1] * x + e[5] * y + e[9] * z;
|
|
1025
|
+
this.z = e[2] * x + e[6] * y + e[10] * z;
|
|
1026
|
+
return this.normalize();
|
|
1027
|
+
}
|
|
1028
|
+
divide(v) {
|
|
1029
|
+
this.x /= v.x;
|
|
1030
|
+
this.y /= v.y;
|
|
1031
|
+
this.z /= v.z;
|
|
1032
|
+
return this;
|
|
1033
|
+
}
|
|
1034
|
+
divideScalar(scalar) {
|
|
1035
|
+
return this.multiplyScalar(1 / scalar);
|
|
1036
|
+
}
|
|
1037
|
+
min(v) {
|
|
1038
|
+
this.x = Math.min(this.x, v.x);
|
|
1039
|
+
this.y = Math.min(this.y, v.y);
|
|
1040
|
+
this.z = Math.min(this.z, v.z);
|
|
1041
|
+
return this;
|
|
1042
|
+
}
|
|
1043
|
+
max(v) {
|
|
1044
|
+
this.x = Math.max(this.x, v.x);
|
|
1045
|
+
this.y = Math.max(this.y, v.y);
|
|
1046
|
+
this.z = Math.max(this.z, v.z);
|
|
1047
|
+
return this;
|
|
1048
|
+
}
|
|
1049
|
+
clamp(min, max) {
|
|
1050
|
+
// assumes min < max, componentwise
|
|
1051
|
+
this.x = Math.max(min.x, Math.min(max.x, this.x));
|
|
1052
|
+
this.y = Math.max(min.y, Math.min(max.y, this.y));
|
|
1053
|
+
this.z = Math.max(min.z, Math.min(max.z, this.z));
|
|
1054
|
+
return this;
|
|
1055
|
+
}
|
|
1056
|
+
clampScalar(minVal, maxVal) {
|
|
1057
|
+
this.x = Math.max(minVal, Math.min(maxVal, this.x));
|
|
1058
|
+
this.y = Math.max(minVal, Math.min(maxVal, this.y));
|
|
1059
|
+
this.z = Math.max(minVal, Math.min(maxVal, this.z));
|
|
1060
|
+
return this;
|
|
1061
|
+
}
|
|
1062
|
+
clampLength(min, max) {
|
|
1063
|
+
const length = this.length();
|
|
1064
|
+
return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));
|
|
1065
|
+
}
|
|
1066
|
+
floor() {
|
|
1067
|
+
this.x = Math.floor(this.x);
|
|
1068
|
+
this.y = Math.floor(this.y);
|
|
1069
|
+
this.z = Math.floor(this.z);
|
|
1070
|
+
return this;
|
|
1071
|
+
}
|
|
1072
|
+
ceil() {
|
|
1073
|
+
this.x = Math.ceil(this.x);
|
|
1074
|
+
this.y = Math.ceil(this.y);
|
|
1075
|
+
this.z = Math.ceil(this.z);
|
|
1076
|
+
return this;
|
|
1077
|
+
}
|
|
1078
|
+
round() {
|
|
1079
|
+
this.x = Math.round(this.x);
|
|
1080
|
+
this.y = Math.round(this.y);
|
|
1081
|
+
this.z = Math.round(this.z);
|
|
1082
|
+
return this;
|
|
1083
|
+
}
|
|
1084
|
+
roundToZero() {
|
|
1085
|
+
this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
|
|
1086
|
+
this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
|
|
1087
|
+
this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
|
|
1088
|
+
return this;
|
|
1089
|
+
}
|
|
1090
|
+
negate() {
|
|
1091
|
+
this.x = -this.x;
|
|
1092
|
+
this.y = -this.y;
|
|
1093
|
+
this.z = -this.z;
|
|
1094
|
+
return this;
|
|
1095
|
+
}
|
|
1096
|
+
dot(v) {
|
|
1097
|
+
return this.x * v.x + this.y * v.y + this.z * v.z;
|
|
1098
|
+
}
|
|
1099
|
+
// TODO lengthSquared?
|
|
1100
|
+
lengthSq() {
|
|
1101
|
+
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
1102
|
+
}
|
|
1103
|
+
length() {
|
|
1104
|
+
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
1105
|
+
}
|
|
1106
|
+
manhattanLength() {
|
|
1107
|
+
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
|
1108
|
+
}
|
|
1109
|
+
normalize() {
|
|
1110
|
+
return this.divideScalar(this.length() || 1);
|
|
1111
|
+
}
|
|
1112
|
+
setLength(length) {
|
|
1113
|
+
return this.normalize().multiplyScalar(length);
|
|
1114
|
+
}
|
|
1115
|
+
lerp(v, alpha) {
|
|
1116
|
+
this.x += (v.x - this.x) * alpha;
|
|
1117
|
+
this.y += (v.y - this.y) * alpha;
|
|
1118
|
+
this.z += (v.z - this.z) * alpha;
|
|
1119
|
+
return this;
|
|
1120
|
+
}
|
|
1121
|
+
lerpVectors(v1, v2, alpha) {
|
|
1122
|
+
this.x = v1.x + (v2.x - v1.x) * alpha;
|
|
1123
|
+
this.y = v1.y + (v2.y - v1.y) * alpha;
|
|
1124
|
+
this.z = v1.z + (v2.z - v1.z) * alpha;
|
|
1125
|
+
return this;
|
|
1126
|
+
}
|
|
1127
|
+
cross(v, w) {
|
|
1128
|
+
if (w !== undefined) {
|
|
1129
|
+
console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.");
|
|
1130
|
+
return this.crossVectors(v, w);
|
|
1131
|
+
}
|
|
1132
|
+
return this.crossVectors(this, v);
|
|
1133
|
+
}
|
|
1134
|
+
crossVectors(a, b) {
|
|
1135
|
+
const ax = a.x, ay = a.y, az = a.z;
|
|
1136
|
+
const bx = b.x, by = b.y, bz = b.z;
|
|
1137
|
+
this.x = ay * bz - az * by;
|
|
1138
|
+
this.y = az * bx - ax * bz;
|
|
1139
|
+
this.z = ax * by - ay * bx;
|
|
1140
|
+
return this;
|
|
1141
|
+
}
|
|
1142
|
+
projectOnVector(v) {
|
|
1143
|
+
const denominator = v.lengthSq();
|
|
1144
|
+
if (denominator === 0)
|
|
1145
|
+
return this.set(0, 0, 0);
|
|
1146
|
+
const scalar = v.dot(this) / denominator;
|
|
1147
|
+
return this.copy(v).multiplyScalar(scalar);
|
|
1148
|
+
}
|
|
1149
|
+
projectOnPlane(planeNormal) {
|
|
1150
|
+
_vector$c.copy(this).projectOnVector(planeNormal);
|
|
1151
|
+
return this.sub(_vector$c);
|
|
1152
|
+
}
|
|
1153
|
+
reflect(normal) {
|
|
1154
|
+
// reflect incident vector off plane orthogonal to normal
|
|
1155
|
+
// normal is assumed to have unit length
|
|
1156
|
+
return this.sub(_vector$c.copy(normal).multiplyScalar(2 * this.dot(normal)));
|
|
1157
|
+
}
|
|
1158
|
+
angleTo(v) {
|
|
1159
|
+
const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
|
|
1160
|
+
if (denominator === 0)
|
|
1161
|
+
return Math.PI / 2;
|
|
1162
|
+
const theta = this.dot(v) / denominator;
|
|
1163
|
+
// clamp, to handle numerical problems
|
|
1164
|
+
return Math.acos(clamp(theta, -1, 1));
|
|
1165
|
+
}
|
|
1166
|
+
distanceTo(v) {
|
|
1167
|
+
return Math.sqrt(this.distanceToSquared(v));
|
|
1168
|
+
}
|
|
1169
|
+
distanceToSquared(v) {
|
|
1170
|
+
const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
|
|
1171
|
+
return dx * dx + dy * dy + dz * dz;
|
|
1172
|
+
}
|
|
1173
|
+
manhattanDistanceTo(v) {
|
|
1174
|
+
return (Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z));
|
|
1175
|
+
}
|
|
1176
|
+
setFromSpherical(s) {
|
|
1177
|
+
return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
|
|
1178
|
+
}
|
|
1179
|
+
setFromSphericalCoords(radius, phi, theta) {
|
|
1180
|
+
const sinPhiRadius = Math.sin(phi) * radius;
|
|
1181
|
+
this.x = sinPhiRadius * Math.sin(theta);
|
|
1182
|
+
this.y = Math.cos(phi) * radius;
|
|
1183
|
+
this.z = sinPhiRadius * Math.cos(theta);
|
|
1184
|
+
return this;
|
|
1185
|
+
}
|
|
1186
|
+
setFromCylindrical(c) {
|
|
1187
|
+
return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
|
|
1188
|
+
}
|
|
1189
|
+
setFromCylindricalCoords(radius, theta, y) {
|
|
1190
|
+
this.x = radius * Math.sin(theta);
|
|
1191
|
+
this.y = y;
|
|
1192
|
+
this.z = radius * Math.cos(theta);
|
|
1193
|
+
return this;
|
|
1194
|
+
}
|
|
1195
|
+
setFromMatrixPosition(m) {
|
|
1196
|
+
const e = m.elements;
|
|
1197
|
+
this.x = e[12];
|
|
1198
|
+
this.y = e[13];
|
|
1199
|
+
this.z = e[14];
|
|
1200
|
+
return this;
|
|
1201
|
+
}
|
|
1202
|
+
setFromMatrixScale(m) {
|
|
1203
|
+
const sx = this.setFromMatrixColumn(m, 0).length();
|
|
1204
|
+
const sy = this.setFromMatrixColumn(m, 1).length();
|
|
1205
|
+
const sz = this.setFromMatrixColumn(m, 2).length();
|
|
1206
|
+
this.x = sx;
|
|
1207
|
+
this.y = sy;
|
|
1208
|
+
this.z = sz;
|
|
1209
|
+
return this;
|
|
1210
|
+
}
|
|
1211
|
+
setFromMatrixColumn(m, index) {
|
|
1212
|
+
return this.fromArray(m.elements, index * 4);
|
|
1213
|
+
}
|
|
1214
|
+
setFromMatrix3Column(m, index) {
|
|
1215
|
+
return this.fromArray(m.elements, index * 3);
|
|
1216
|
+
}
|
|
1217
|
+
equals(v) {
|
|
1218
|
+
return v.x === this.x && v.y === this.y && v.z === this.z;
|
|
1219
|
+
}
|
|
1220
|
+
fromArray(array, offset = 0) {
|
|
1221
|
+
this.x = array[offset];
|
|
1222
|
+
this.y = array[offset + 1];
|
|
1223
|
+
this.z = array[offset + 2];
|
|
1224
|
+
return this;
|
|
1225
|
+
}
|
|
1226
|
+
toArray(array = [], offset = 0) {
|
|
1227
|
+
array[offset] = this.x;
|
|
1228
|
+
array[offset + 1] = this.y;
|
|
1229
|
+
array[offset + 2] = this.z;
|
|
1230
|
+
return array;
|
|
1231
|
+
}
|
|
1232
|
+
fromBufferAttribute(attribute, index, offset) {
|
|
1233
|
+
if (offset !== undefined) {
|
|
1234
|
+
console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");
|
|
1235
|
+
}
|
|
1236
|
+
this.x = attribute.getX(index);
|
|
1237
|
+
this.y = attribute.getY(index);
|
|
1238
|
+
this.z = attribute.getZ(index);
|
|
1239
|
+
return this;
|
|
1240
|
+
}
|
|
1241
|
+
random() {
|
|
1242
|
+
this.x = Math.random();
|
|
1243
|
+
this.y = Math.random();
|
|
1244
|
+
this.z = Math.random();
|
|
1245
|
+
return this;
|
|
1246
|
+
}
|
|
1247
|
+
randomDirection() {
|
|
1248
|
+
// Derived from https://mathworld.wolfram.com/SpherePointPicking.html
|
|
1249
|
+
const u = (Math.random() - 0.5) * 2;
|
|
1250
|
+
const t = Math.random() * Math.PI * 2;
|
|
1251
|
+
const f = Math.sqrt(1 - u ** 2);
|
|
1252
|
+
this.x = f * Math.cos(t);
|
|
1253
|
+
this.y = f * Math.sin(t);
|
|
1254
|
+
this.z = u;
|
|
1255
|
+
return this;
|
|
1256
|
+
}
|
|
1257
|
+
*[Symbol.iterator]() {
|
|
1258
|
+
yield this.x;
|
|
1259
|
+
yield this.y;
|
|
1260
|
+
yield this.z;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
Vector3.prototype.isVector3 = true;
|
|
1264
|
+
//#endregion
|
|
1265
|
+
//# sourceMappingURL=load-model.js.map
|