UNPKG

x_ite

Version:

X_ITE X3D Browser, view and manipulate X3D, VRML, glTF and other 3D sources in HTML.

1,703 lines (1,482 loc) 4.33 MB
/* X_ITE v11.5.0 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["X3D"] = factory(); else root["X3D"] = factory(); })(self, () => { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 37: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1497); /* harmony import */ var _Namespace_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1510); /******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the X_ITE Project. * * X_ITE is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ const _array = Symbol (), _index = Symbol (), _valueType = Symbol (); const handler = { get (target, key) { const value = target [key]; if (value !== undefined) return value; if (typeof key === "string") { const index = +key; if (Number .isInteger (index)) return target [_array] [index]; return; } }, set (target, key, value) { if (target [key] === undefined) return false; target [key] = value; return true; }, has (target, key) { if (Number .isInteger (+key)) return key < target [_array] .length; return key in target; }, ownKeys (target) { return Object .keys (target [_array]); }, getOwnPropertyDescriptor (target, key) { if (typeof key !== "string") return; const index = +key; if (Number .isInteger (index) && index < target [_array] .length) { const propertyDescriptor = Object .getOwnPropertyDescriptor (target [_array], key); if (propertyDescriptor) propertyDescriptor .writable = false; return propertyDescriptor; } }, }; function X3DInfoArray (values, valueType) { const proxy = new Proxy (this, handler); _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .call (this); this [_array] = [ ]; this [_index] = new Map (); this [_valueType] = valueType; for (const [key, value] of values) this .add (key, value); return proxy; } Object .assign (Object .setPrototypeOf (X3DInfoArray .prototype, _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .prototype), { *[Symbol .iterator] () { yield* this [_array]; }, copy () { const copy = new (this .constructor) (); copy .assign (this); return copy; }, clear () { this [_array] .length = 0; this [_index] .clear (); this .addEvent (); }, assign (array) { if (!(array instanceof this .constructor)) throw new Error ("Couldn't assign info array, wrong type."); this [_array] = Array .from (array [_array]); this [_index] = new Map (array [_index]); this .addEvent (); }, equals (array) { const a = this [_array], b = array [_array], length = a .length; if (a === b) return true; if (length !== b .length) return false; for (let i = 0; i < length; ++ i) { if (a [i] !== b [i]) return false; } return true; }, has (key) { return this [_index] .has (key); }, get (key) { return this [_index] .get (key); }, add (key, value) { if (this [_index] .has (key)) throw new Error (`Couldn't add value to ${this .getTypeName ()}, key '${key}' already exists.`); if (!(value instanceof this [_valueType])) throw new Error (`Couldn't add value to ${this .getTypeName ()}, value for key '${key}' has wrong type.`); this [_array] .push (value); this [_index] .set (key, value); this .addEvent (); }, alias (alias, value) { this [_index] .set (alias, value); this .addEvent (); }, update (oldKey, newKey, value) { // TODO: update alias. if (!(value instanceof this [_valueType])) throw new Error (`Couldn't update value of ${this .getTypeName ()}, value for key '${key}' has wrong type.`); const oldValue = this [_index] .get (oldKey); if (oldKey !== newKey) this .remove (newKey); this [_index] .delete (oldKey); this [_index] .set (newKey, value); if (oldValue !== undefined) { const index = this [_array] .indexOf (oldValue); if (index > -1) this [_array] [index] = value; } else { this [_array] .push (value); } this .addEvent (); }, remove (key) { // TODO: remove alias. const value = this [_index] .get (key); if (value === undefined) return; const index = this [_array] .indexOf (value); this [_index] .delete (key); if (index > -1) this [_array] .splice (index, 1); this .addEvent (); }, at: Array .prototype .at, // concat: Array .prototype .concat, // copyWithin: Array.prototype.copyWithin, entries: Array .prototype .entries, every: Array .prototype .every, // fill: Array .prototype .fill, filter (callbackFn, thisArg) { return new (this .constructor) (Array .prototype .filter .call (this, callbackFn, thisArg)); }, find: Array .prototype .find, findIndex: Array .prototype .findIndex, findLast: Array .prototype .findLast, findLastIndex: Array .prototype .findLastIndex, flat: Array .prototype .flat, flatMap: Array .prototype .flatMap, forEach: Array .prototype .forEach, includes: Array .prototype .includes, indexOf: Array .prototype .indexOf, join: Array .prototype .join, keys: Array .prototype .keys, lastIndexOf: Array .prototype .lastIndexOf, map (callbackFn, thisArg) { return new (this .constructor) (Array .prototype .map .call (this, callbackFn, thisArg)); }, reduce: Array .prototype .reduce, reduceRight: Array .prototype .reduceRight, // reverse: Array .prototype .reverse, slice (start, end) { return new (this .constructor) (Array .prototype .slice .call (this, start, end)); }, some: Array .prototype .some, // sort: Array .prototype .sort, toReversed () { return new (this .constructor) ([... this] .reverse ()); }, toSorted (compareFn) { return new (this .constructor) ([... this] .sort (compareFn)); }, toSpliced (start, deleteCount, ... insertValues) { const array = [... this]; array .splice (start, deleteCount, ... insertValues) return new (this .constructor) (array); }, values: Array .prototype .values, with (index, value) { const array = [... this]; array [index] = value; return new (this .constructor) (array); }, toVRMLStream (generator) { for (const value of this [_array]) { try { value .toVRMLStream (generator); generator .string += generator .Break (); if (this .getTypeName () .match (/Proto/)) generator .string += generator .TidyBreak (); } catch (error) { // console .error (error); } } }, toXMLStream (generator) { for (const value of this [_array]) { try { value .toXMLStream (generator); generator .string += generator .TidyBreak (); } catch (error) { // console .error (error); } } }, toJSONStream (generator, comma) { let lastProperty = false; for (const value of this [_array]) { try { value .toJSONStream (generator, true); generator .string += ','; generator .string += generator .TidyBreak (); lastProperty = true; } catch (error) { // console .error (error); } } if (lastProperty && !comma) generator .JSONRemoveComma (); return lastProperty; }, }); for (const key of Object .keys (X3DInfoArray .prototype)) Object .defineProperty (X3DInfoArray .prototype, key, { enumerable: false }); Object .defineProperties (X3DInfoArray .prototype, { length: { get () { return this [_array] .length; }, }, }); const __default__ = X3DInfoArray; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Namespace_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .add ("X3DInfoArray", __default__)); /***/ }), /***/ 93: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _Vector3_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4817); /* harmony import */ var _Matrix3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2798); /* harmony import */ var _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8533); /* harmony import */ var _x_ite_Namespace_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1510); /******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the X_ITE Project. * * X_ITE is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ function Quaternion (x = 0, y = 0, z = 0, w = 1) { this .x = x; this .y = y; this .z = z; this .w = w; } Object .assign (Quaternion .prototype, { *[Symbol .iterator] () { yield this .x; yield this .y; yield this .z; yield this .w; }, copy () { const copy = Object .create (Quaternion .prototype); copy .x = this .x; copy .y = this .y; copy .z = this .z; copy .w = this .w; return copy; }, assign ({ x, y, z, w }) { this .x = x; this .y = y; this .z = z; this .w = w; return this; }, set (x = 0, y = 0, z = 0, w = 1) { this .x = x; this .y = y; this .z = z; this .w = w; return this; }, setMatrix (matrix) { // First, find largest diagonal in matrix: if (matrix [0] > matrix [4]) { var i = matrix [0] > matrix [8] ? 0 : 2; } else { var i = matrix [4] > matrix [8] ? 1 : 2; } const scaleRow = matrix [0] + matrix [4] + matrix [8]; if (scaleRow > matrix [i * 3 + i]) { // Compute w first: this [3] = Math .sqrt (scaleRow + 1) / 2; // And compute other values: const d = 4 * this [3]; this [0] = (matrix [5] - matrix [7]) / d; this [1] = (matrix [6] - matrix [2]) / d; this [2] = (matrix [1] - matrix [3]) / d; } else { // Compute x, y, or z first: const j = (i + 1) % 3; const k = (i + 2) % 3; // Compute first value: this [i] = Math .sqrt (matrix [i * 3 + i] - matrix [j * 3 + j] - matrix [k * 3 + k] + 1) / 2; // And the others: const d = 4 * this [i]; this [j] = (matrix [i * 3 + j] + matrix [j * 3 + i]) / d; this [k] = (matrix [i * 3 + k] + matrix [k * 3 + i]) / d; this [3] = (matrix [j * 3 + k] - matrix [k * 3 + j]) / d; } return this; }, getMatrix (matrix = new _Matrix3_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A ()) { const { x, y, z, w } = this; const a = x * x, b = x * y, c = y * y, d = y * z, e = z * x, f = z * z, g = w * x, h = w * y, i = w * z; matrix [0] = 1 - 2 * (c + f); matrix [1] = 2 * (b + i); matrix [2] = 2 * (e - h); matrix [3] = 2 * (b - i); matrix [4] = 1 - 2 * (f + a); matrix [5] = 2 * (d + g); matrix [6] = 2 * (e + h); matrix [7] = 2 * (d - g); matrix [8] = 1 - 2 * (c + a); return matrix; }, setEuler (x, y, z, order = "XYZ") { // http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m const c1 = Math .cos (x / 2), c2 = Math .cos (y / 2), c3 = Math .cos (z / 2), s1 = Math .sin (x / 2), s2 = Math .sin (y / 2), s3 = Math .sin (z / 2); switch (order) { case "XYZ": this .x = s1 * c2 * c3 + c1 * s2 * s3; this .y = c1 * s2 * c3 - s1 * c2 * s3; this .z = c1 * c2 * s3 + s1 * s2 * c3; this .w = c1 * c2 * c3 - s1 * s2 * s3; break; case "ZYX": this .x = s1 * c2 * c3 - c1 * s2 * s3; this .y = c1 * s2 * c3 + s1 * c2 * s3; this .z = c1 * c2 * s3 - s1 * s2 * c3; this .w = c1 * c2 * c3 + s1 * s2 * s3; break; case "YXZ": this .x = s1 * c2 * c3 + c1 * s2 * s3; this .y = c1 * s2 * c3 - s1 * c2 * s3; this .z = c1 * c2 * s3 - s1 * s2 * c3; this .w = c1 * c2 * c3 + s1 * s2 * s3; break; case "ZXY": this .x = s1 * c2 * c3 - c1 * s2 * s3; this .y = c1 * s2 * c3 + s1 * c2 * s3; this .z = c1 * c2 * s3 + s1 * s2 * c3; this .w = c1 * c2 * c3 - s1 * s2 * s3; break; case "YZX": this .x = s1 * c2 * c3 + c1 * s2 * s3; this .y = c1 * s2 * c3 + s1 * c2 * s3; this .z = c1 * c2 * s3 - s1 * s2 * c3; this .w = c1 * c2 * c3 - s1 * s2 * s3; break; case "XZY": this .x = s1 * c2 * c3 - c1 * s2 * s3; this .y = c1 * s2 * c3 - s1 * c2 * s3; this .z = c1 * c2 * s3 + s1 * s2 * c3; this .w = c1 * c2 * c3 + s1 * s2 * s3; break; } return this; }, getEuler (euler = [ ], order = "XYZ") { const { 0: m0, 1: m1, 2: m2, 3: m3, 4: m4, 5: m5, 6: m6, 7: m7, 8: m8 } = this .getMatrix (m); switch (order) { case "XYZ": { euler [1] = Math .asin (_Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m6, -1, 1)); if (Math .abs (m6) < 0.9999999) { euler [0] = Math .atan2 (-m7, m8); euler [2] = Math .atan2 (-m3, m0); } else { euler [0] = Math .atan2 (m5, m4); euler [2] = 0; } break; } case "ZYX": { euler [1] = Math .asin (- _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m2, -1, 1)); if (Math .abs (m2) < 0.9999999) { euler [0] = Math .atan2 (m5, m8); euler [2] = Math .atan2 (m1, m0); } else { euler [0] = 0; euler [2] = Math .atan2 (-m3, m4); } break; } case "YXZ": { euler [0] = Math .asin (- _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m7, -1, 1)); if (Math .abs (m7) < 0.9999999) { euler [1] = Math .atan2 (m6, m8); euler [2] = Math .atan2 (m1, m4); } else { euler [1] = Math .atan2 (-m2, m0); euler [2] = 0; } break; } case "ZXY": { euler [0] = Math .asin (_Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m5, -1, 1)); if (Math .abs (m5) < 0.9999999) { euler [1] = Math .atan2 (-m2, m8); euler [2] = Math .atan2 (-m3, m4); } else { euler [1] = 0; euler [2] = Math .atan2 (m1, m0); } break; } case "YZX": { euler [2] = Math .asin (_Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m1, -1, 1)); if (Math .abs (m1) < 0.9999999) { euler [0] = Math .atan2 (-m7, m4); euler [1] = Math .atan2 (-m2, m0); } else { euler [0] = 0; euler [1] = Math .atan2 (m6, m8); } break; } case "XZY": { euler [2] = Math .asin (- _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .clamp (m3, -1, 1)); if (Math .abs (m3) < 0.9999999) { euler [0] = Math .atan2 (m5, m4); euler [1] = Math .atan2 (m6, m0); } else { euler [0] = Math .atan2 (-m7, m8); euler [1] = 0; } break; } } return euler; }, isReal () { return !(this .x || this .y || this .z); }, isImag () { return !this .w; }, equals ({ x, y, z, w }) { return this .x === x && this .y === y && this .z === z && this .w === w; }, negate () { this .x = -this .x; this .y = -this .y; this .z = -this .z; this .w = -this .w; return this; }, inverse () { this .x = -this .x; this .y = -this .y; this .z = -this .z; return this; }, add ({ x, y, z, w }) { this .x += x; this .y += y; this .z += z; this .w += w; return this; }, subtract ({ x, y, z, w }) { this .x -= x; this .y -= y; this .z -= z; this .w -= w; return this; }, multiply (value) { this .x *= value; this .y *= value; this .z *= value; this .w *= value; return this; }, multLeft (quat) { const { x: ax, y: ay, z: az, w: aw } = this, { x: bx, y: by, z: bz, w: bw } = quat; this .x = aw * bx + ax * bw + ay * bz - az * by; this .y = aw * by + ay * bw + az * bx - ax * bz; this .z = aw * bz + az * bw + ax * by - ay * bx; this .w = aw * bw - ax * bx - ay * by - az * bz; return this; }, multRight (quat) { const { x: ax, y: ay, z: az, w: aw } = this, { x: bx, y: by, z: bz, w: bw } = quat; this .x = bw * ax + bx * aw + by * az - bz * ay; this .y = bw * ay + by * aw + bz * ax - bx * az; this .z = bw * az + bz * aw + bx * ay - by * ax; this .w = bw * aw - bx * ax - by * ay - bz * az; return this; }, divide (value) { this .x /= value; this .y /= value; this .z /= value; this .w /= value; return this; }, multVecQuat (vector) { // https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Vector_rotation const { x: qx, y: qy, z: qz, w: qw } = this, { x: vx, y: vy, z: vz } = vector, tx = 2 * (qy * vz - qz * vy), ty = 2 * (qz * vx - qx * vz), tz = 2 * (qx * vy - qy * vx); vector .x += qw * tx + qy * tz - qz * ty; vector .y += qw * ty + qz * tx - qx * tz; vector .z += qw * tz + qx * ty - qy * tx; return vector; }, multQuatVec (vector) { // https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Vector_rotation const { x: qx, y: qy, z: qz, w: qw } = this, { x: vx, y: vy, z: vz } = vector, tx = 2 * (qz * vy - qy * vz), ty = 2 * (qx * vz - qz * vx), tz = 2 * (qy * vx - qx * vy); vector .x += qw * tx - qy * tz + qz * ty; vector .y += qw * ty - qz * tx + qx * tz; vector .z += qw * tz - qx * ty + qy * tx; return vector; }, normalize () { const length = Math .hypot (this .x, this .y, this .z, this .w); if (length) { this .x /= length; this .y /= length; this .z /= length; this .w /= length; } return this; }, dot (quat) { return this .x * quat .x + this .y * quat .y + this .z * quat .z + this .w * quat .w; }, norm () { const { x, y, z, w } = this; return x * x + y * y + z * z + w * w; }, magnitude () { return Math .hypot (this .x, this .y, this .z, this .w); }, pow (exponent) { if (exponent instanceof Quaternion) return this .assign (e .assign (exponent) .multRight (this .log ()) .exp ()); if (this .isReal ()) return this .set (0, 0, 0, this .w ** exponent); const l = this .magnitude (), theta = Math .acos (this .w / l), li = this .imag .magnitude (), ltoe = l ** exponent, et = exponent * theta, scale = ltoe / li * Math .sin (et); this .x *= scale; this .y *= scale; this .z *= scale; this .w = ltoe * Math .cos (et); return this; }, log () { if (this .isReal ()) { if (this .w > 0) return this .set (0, 0, 0, Math .log (this .w)); else return this .set (Math .PI, 0, 0, Math .log (-this .w)); } const l = this .magnitude (), v = this .imag .normalize () .multiply (Math .acos (this .w / l)), w = Math .log (l); this .x = v .x; this .y = v .y; this .z = v .z; this .w = w; return this; }, exp () { if (this .isReal ()) return this .set (0, 0, 0, Math .exp (this .w)); const i = this .imag, li = i .magnitude (), ew = Math .exp (this .w), w = ew * Math .cos (li), v = i .multiply (ew * Math .sin (li) / li); this .x = v .x; this .y = v .y; this .z = v .z; this .w = w; return this; }, slerp (destination, t) { return _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .slerp (this, t1 .assign (destination), t); }, squad (a, b, destination, t) { // We must use shortest path slerp to prevent flipping. Also see spline. return _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .slerp (_Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .slerp (this, t1 .assign (destination), t), _Algorithm_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .slerp (t2 .assign (a), t3 .assign (b), t), 2 * t * (1 - t)); }, toString () { return this .x + " " + this .y + " " + this .z + " " + this .w; }, }); for (const key of Object .keys (Quaternion .prototype)) Object .defineProperty (Quaternion .prototype, key, { enumerable: false }); Object .defineProperties (Quaternion .prototype, { length: { value: 4 }, 0: { get () { return this .x; }, set (value) { this .x = value; }, }, 1: { get () { return this .y; }, set (value) { this .y = value; }, }, 2: { get () { return this .z; }, set (value) { this .z = value; }, }, 3: { get () { return this .w; }, set (value) { this .w = value; }, }, real: { get () { return this .w; }, }, imag: { get: (() => { const result = new _Vector3_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A (); return function () { return result .set (this .x, this .y, this .z); }; })(), }, }); Object .assign (Quaternion, { Identity: Object .freeze (new Quaternion ()), spline: (() => { const q0 = new Quaternion (), q1 = new Quaternion (), q2 = new Quaternion (), q1_i = new Quaternion (); return function (Q0, Q1, Q2) { q0 .assign (Q0); q1 .assign (Q1); q2 .assign (Q2); // If the dot product is smaller than 0 we must negate the quaternion to prevent flipping. If we negate all // the terms we get a different quaternion but it represents the same rotation. if (q0 .dot (q1) < 0) q0 .negate (); if (q2 .dot (q1) < 0) q2 .negate (); q1_i .assign (q1) .inverse (); // The result must be normalized as it will be used in slerp and we can only slerp normalized vectors. return q1 .multRight ( t1 .assign (q1_i) .multRight (q0) .log () .add (t2 .assign (q1_i) .multRight (q2) .log ()) .divide (-4) .exp () ) .normalize () .copy (); }; })(), }); const t1 = new Quaternion (), t2 = new Quaternion (), t3 = new Quaternion (), m = new _Matrix3_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A (); const __default__ = Quaternion; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_x_ite_Namespace_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A .add ("Quaternion", __default__)); /***/ }), /***/ 216: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1497); /* harmony import */ var _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8041); /* harmony import */ var _Events_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4180); /* harmony import */ var _IterableWeakSet_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8035); /* harmony import */ var _Namespace_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1510); /******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the X_ITE Project. * * X_ITE is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ const _value = Symbol (), _accessType = Symbol (), _unit = Symbol (), _references = Symbol (), _referencesCallbacks = Symbol (), _fieldInterests = Symbol (), _fieldCallbacks = Symbol (), _inputRoutes = Symbol (), _outputRoutes = Symbol (), _routeCallbacks = Symbol (), _uniformLocation = Symbol .for ("X_ITE.X3DField.uniformLocation"); const EMPTY = [ ]; function X3DField (value) { _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .call (this); this [_value] = value; } Object .assign (Object .setPrototypeOf (X3DField .prototype, _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .prototype), { [_value]: undefined, [_accessType]: _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .initializeOnly, [_unit]: undefined, [_references]: null, [_referencesCallbacks]: null, [_fieldInterests]: null, [_fieldCallbacks]: null, [_inputRoutes]: null, [_outputRoutes]: null, [_routeCallbacks]: null, [_uniformLocation]: null, create () { return new (this .constructor) (); }, equals (field) { return this [_value] === field .valueOf (); }, assign (field) { // Assigns field to this field. this .set (field .getValue ()); this .addEvent (); }, set (value) { // Sets internal value without generating event. this [_value] = value; }, setValue (value) { // Sets internal value and generates event. this .set (value instanceof this .constructor ? value .getValue () : value); this .addEvent (); }, getValue () { return this [_value]; }, getType () { return _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A [this .constructor .typeName]; }, setAccessType (value) { this [_accessType] = value; }, getAccessType () { return this [_accessType]; }, isInitializable () { return !! (this [_accessType] & _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .initializeOnly); }, isInput () { return !! (this [_accessType] & _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOnly); }, isOutput () { return !! (this [_accessType] & _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .outputOnly); }, isReadable () { return this [_accessType] !== _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOnly; }, isWritable () { return this [_accessType] !== _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .outputOnly; }, setUnit (value) { this [_unit] = value; }, getUnit () { return this [_unit]; }, isReference (accessType) { return accessType === this [_accessType] || accessType === _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOutput; }, addReference (reference) { const references = this .getReferences (); if (references .has (reference)) return; references .add (reference); // Create IS relationship switch (this .getAccessType () & reference .getAccessType ()) { case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .initializeOnly: reference .addFieldInterest (this); this .processEvent (_Events_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .from (reference)); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOnly: reference .addFieldInterest (this); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .outputOnly: this .addFieldInterest (reference); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOutput: reference .addFieldInterest (this); this .addFieldInterest (reference); this .processEvent (_Events_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .from (reference)); break; } this .processReferencesCallbacks (); }, removeReference (reference) { this [_references] ?.delete (reference); // Create IS relationship switch (this .getAccessType () & reference .getAccessType ()) { case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .initializeOnly: reference .removeFieldInterest (this); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOnly: reference .removeFieldInterest (this); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .outputOnly: this .removeFieldInterest (reference); break; case _X3DConstants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .inputOutput: reference .removeFieldInterest (this); this .removeFieldInterest (reference); break; } this .processReferencesCallbacks (); }, getReferences () { return this [_references] ??= new _IterableWeakSet_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A (); }, addReferencesCallback (key, object) { this [_referencesCallbacks] = new Map (this [_referencesCallbacks]); this [_referencesCallbacks] .set (key, object); }, removeReferencesCallback (key) { this [_referencesCallbacks] ?.delete (key); }, getReferencesCallbacks () { return this [_referencesCallbacks] ??= new Map (); }, processReferencesCallbacks () { for (const callback of this [_referencesCallbacks] ?.values () ?? EMPTY) callback (); }, addFieldInterest (field) { // There must be no copy, because the event is not executed immediately. this .getFieldInterests () .add (field); }, removeFieldInterest (field) { this [_fieldInterests] ?.delete (field); }, getFieldInterests () { return this [_fieldInterests] ??= new _IterableWeakSet_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A (); }, addFieldCallback (key, object) { this [_fieldCallbacks] = new Map (this [_fieldCallbacks]); this [_fieldCallbacks] .set (key, object); }, removeFieldCallback (key) { this [_fieldCallbacks] ?.delete (key); }, getFieldCallbacks () { return this [_fieldCallbacks] ??= new Map (); }, addInputRoute (route) { this .getInputRoutes () .add (route); this .processRouteCallbacks (); }, removeInputRoute (route) { this [_inputRoutes] ?.delete (route); this .processRouteCallbacks (); }, getInputRoutes () { return this [_inputRoutes] ??= new _IterableWeakSet_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A (); }, addOutputRoute (route) { this .getOutputRoutes () .add (route); this .processRouteCallbacks (); }, removeOutputRoute (route) { this [_outputRoutes] ?.delete (route); this .processRouteCallbacks (); }, getOutputRoutes () { return this [_outputRoutes] ??= new _IterableWeakSet_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A (); }, addRouteCallback (key, object) { // Processed if routes are changed. this [_routeCallbacks] = new Map (this [_routeCallbacks]); this [_routeCallbacks] .set (key, object); }, removeRouteCallback (key) { this [_routeCallbacks] ?.delete (key); }, getRouteCallbacks () { return this [_routeCallbacks] ??= new Map (); }, processRouteCallbacks () { for (const callback of this [_routeCallbacks] ?.values () ?? EMPTY) callback (); }, processEvent (event = _Events_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .create (this)) { event .add (this); this .setTainted (false); const field = event .field; if (field !== this) this .set (field .getValue (), field .length); // Process interests. this .processInterests (); // Process routes. let first = true; for (const field of this [_fieldInterests] ?? EMPTY) { if (event .has (field)) continue; if (first) { first = false; field .addEventObject (this, event); } else { field .addEventObject (this, _Events_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .copy (event)); } } if (first) _Events_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .push (event); // Process field callbacks. for (const callback of this [_fieldCallbacks] ?.values () ?? EMPTY) callback (this .valueOf ()); }, fromString (string, scene) { // Function will be overridden in VRMLParser. }, dispose () { for (const reference of this [_references] ?? EMPTY) reference .removeFieldInterest (this); for (const route of new Set (this [_inputRoutes])) route .dispose (); for (const route of new Set (this [_outputRoutes])) route .dispose (); this [_references] ?.clear (); this [_referencesCallbacks] ?.clear (); this [_fieldInterests] ?.clear (); this [_fieldCallbacks] ?.clear (); this [_inputRoutes] ?.clear (); this [_outputRoutes] ?.clear (); this [_routeCallbacks] ?.clear (); _X3DChildObject_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .prototype .dispose .call (this); } }); for (const key of Object .keys (X3DField .prototype)) Object .defineProperty (X3DField .prototype, key, { enumerable: false }); const __default__ = X3DField; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Namespace_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A .add ("X3DField", __default__)); /***/ }), /***/ 225: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _Base_X3DInfoArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(37); /* harmony import */ var _Fields_SFNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7204); /* harmony import */ var _Namespace_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1510); /******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the X_ITE Project. * * X_ITE is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ function NamedNodesArray (values = [ ]) { return _Base_X3DInfoArray_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .call (this, Array .from (values, value => [value .getNodeName (), value]), _Fields_SFNode_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A); } Object .setPrototypeOf (NamedNodesArray .prototype, _Base_X3DInfoArray_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .prototype); for (const key of Object .keys (NamedNodesArray .prototype)) Object .defineProperty (NamedNodesArray .prototype, key, { enumerable: false }); Object .defineProperties (NamedNodesArray, { typeName: { value: "NamedNodesArray", enumerable: true, }, }); const __default__ = NamedNodesArray; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Namespace_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .add ("NamedNodesArray", __default__)); /***/ }), /***/ 254: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _Fields_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2844); /* harmony import */ var _Base_X3DFieldDefinition_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9281); /* harmony import */ var _Base_FieldDefinitionArray_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1715); /* harmony import */ var _Core_X3DNode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7693); /* harmony import */ var _X3DInterpolatorNode_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8431); /* harmony import */ var _Base_X3DConstants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8041); /* harmony import */ var _standard_Math_Numbers_Rotation4_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5835); /* harmony import */ var _Namespace_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1510); /******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the X_ITE Project. * * X_ITE is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ function OrientationInterpolator (executionContext) { _X3DInterpolatorNode_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A .call (this, executionContext); this .addType (_Base_X3DConstants_js__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A .OrientationInterpolator); // Units this ._keyValue .setUnit ("angle"); this ._value_changed .setUnit ("angle"); } Object .assign (Object .setPrototypeOf (OrientationInterpolator .prototype, _X3DInterpolatorNode_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A .prototype), { initialize () { _X3DInterpolatorNode_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A .prototype .initialize .call (this); this ._keyValue .addInterest ("set_keyValue__", this); }, set_keyValue__ () { const key = this ._key, keyValue = this ._keyValue; if (keyValue .length < key .length) keyValue .resize (key .length, keyValue .length ? keyValue [keyValue .length - 1] : new _Fields_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .SFRotation ()); }, interpolate: (() => { const keyValue0 = new _standard_Math_Numbers_Rotation4_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A (), keyValue1 = new _standard_Math_Numbers_Rotation4_js__WEBPACK_IMPORTED_MOD