UNPKG

x_ite

Version:

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

1,757 lines (1,445 loc) 3.42 MB
/* X_ITE v12.2.4 */ (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__ = ({ /***/ 477 (__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 _Algorithm_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5185); /* harmony import */ var _x_ite_Namespace_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2696); function Vector3 (x = 0, y = x, z = y) { this .x = x; this .y = y; this .z = z; } Object .assign (Vector3 .prototype, { *[Symbol .iterator] () { yield this .x; yield this .y; yield this .z; }, copy () { const copy = Object .create (Vector3 .prototype); copy .x = this .x; copy .y = this .y; copy .z = this .z; return copy; }, assign ({ x, y, z }) { this .x = x; this .y = y; this .z = z; return this; }, set (x = 0, y = x, z = y) { this .x = x; this .y = y; this .z = z; return this; }, equals ({ x, y, z }) { return this .x === x && this .y === y && this .z === z; }, negate () { this .x = -this .x; this .y = -this .y; this .z = -this .z; return this; }, inverse () { this .x = 1 / this .x; this .y = 1 / this .y; this .z = 1 / this .z; return this; }, add ({ x, y, z }) { this .x += x; this .y += y; this .z += z; return this; }, subtract ({ x, y, z }) { this .x -= x; this .y -= y; this .z -= z; return this; }, multiply (value) { this .x *= value; this .y *= value; this .z *= value; return this; }, multVec ({ x, y, z }) { this .x *= x; this .y *= y; this .z *= z; return this; }, divide (value) { this .x /= value; this .y /= value; this .z /= value; return this; }, divVec ({ x, y, z }) { this .x /= x; this .y /= y; this .z /= z; return this; }, cross ({ x: bx, y: by, z: bz }) { const { x: ax, y: ay, z: az } = this; this .x = ay * bz - az * by; this .y = az * bx - ax * bz; this .z = ax * by - ay * bx; return this; }, normalize () { const length = Math .hypot (this .x, this .y, this .z); if (length) { this .x /= length; this .y /= length; this .z /= length; } return this; }, dot ({ x, y, z }) { return this .x * x + this .y * y + this .z * z; }, squaredNorm () { const { x, y, z } = this; return x * x + y * y + z * z; }, norm () { return Math .hypot (this .x, this .y, this .z); }, distance ({ x, y, z }) { return Math .hypot (this .x - x, this .y - y, this .z - z); }, lerp ({ x: dX, y: dY, z: dZ }, t) { const { x, y, z } = this; this .x = x + t * (dX - x); this .y = y + t * (dY - y); this .z = z + t * (dZ - z); return this; }, slerp: (() => { const tmp = new Vector3 (); return function (destination, t) { return _Algorithm_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .simpleSlerp (this, tmp .assign (destination), t); }; })(), abs () { const { x, y, z } = this; this .x = Math .abs (x); this .y = Math .abs (y); this .z = Math .abs (z); return this; }, min (vector) { let { x, y, z } = this; for (const { x: minX, y: minY, z: minZ } of arguments) { x = Math .min (x, minX); y = Math .min (y, minY); z = Math .min (z, minZ); } this .x = x; this .y = y; this .z = z; return this; }, max (vector) { let { x, y, z } = this; for (const { x: maxX, y: maxY, z: maxZ } of arguments) { x = Math .max (x, maxX); y = Math .max (y, maxY); z = Math .max (z, maxZ); } this .x = x; this .y = y; this .z = z; return this; }, clamp ({ x: minX, y: minY, z: minZ }, { x: maxX, y: maxY, z: maxZ }) { this .x = _Algorithm_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .clamp (this .x, minX, maxX); this .y = _Algorithm_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .clamp (this .y, minY, maxY); this .z = _Algorithm_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .clamp (this .z, minZ, maxZ); return this; }, toString () { return this .x + " " + this .y + " " + this .z; } }); for (const key of Object .keys (Vector3 .prototype)) Object .defineProperty (Vector3 .prototype, key, { enumerable: false }); Object .defineProperties (Vector3 .prototype, { length: { value: 3 }, 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; }, }, }); Object .assign (Vector3, { ZERO: Object .freeze (new Vector3 ()), // Positive values ONE: Object .freeze (new Vector3 (1)), X_AXIS: Object .freeze (new Vector3 (1, 0, 0)), Y_AXIS: Object .freeze (new Vector3 (0, 1, 0)), Z_AXIS: Object .freeze (new Vector3 (0, 0, 1)), // Negative values NEGATIVE_ONE: Object .freeze (new Vector3 (-1)), NEGATIVE_X_AXIS: Object .freeze (new Vector3 (-1, 0, 0)), NEGATIVE_Y_AXIS: Object .freeze (new Vector3 (0, -1, 0)), NEGATIVE_Z_AXIS: Object .freeze (new Vector3 (0, 0, -1)), }); const __default__ = Vector3; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_x_ite_Namespace_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A .add ("Vector3", __default__)); /***/ }, /***/ 608 (__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 _Namespace_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2696); let i = 0; const TraverseType = Object .freeze ({ BBOX: i ++, POINTER: i ++, CAMERA: i ++, PICKING: i ++, COLLISION: i ++, SHADOW: i ++, DISPLAY: i ++, }); const __default__ = TraverseType; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Namespace_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .add ("TraverseType", __default__)); /***/ }, /***/ 611 (__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__(3097); /* harmony import */ var _X3DExternProtoDeclaration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2417); /* harmony import */ var _Namespace_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2696); function ExternProtoDeclarationArray (values = [ ]) { return _Base_X3DInfoArray_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .call (this, Array .from (values, value => [value .name, value]), _X3DExternProtoDeclaration_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A); } Object .setPrototypeOf (ExternProtoDeclarationArray .prototype, _Base_X3DInfoArray_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A .prototype); for (const key of Object .keys (ExternProtoDeclarationArray .prototype)) Object .defineProperty (ExternProtoDeclarationArray .prototype, key, { enumerable: false }); Object .defineProperties (ExternProtoDeclarationArray, { typeName: { value: "ExternProtoDeclarationArray", enumerable: true, }, }); const __default__ = ExternProtoDeclarationArray; ; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Namespace_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A .add ("ExternProtoDeclarationArray", __default__)); /***/ }, /***/ 620 (module) { (function webpackUniversalModuleDefinition(root, factory) { if(true) module.exports = factory(); else // removed by dead control flow {} })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __nested_webpack_require_529__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_529__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __nested_webpack_require_529__.m = modules; /******/ // expose the module cache /******/ __nested_webpack_require_529__.c = installedModules; /******/ // __webpack_public_path__ /******/ __nested_webpack_require_529__.p = ""; /******/ // Load entry module and return exports /******/ return __nested_webpack_require_529__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __nested_webpack_require_1730__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNotPNG = isNotPNG; exports.isNotAPNG = isNotAPNG; exports.default = parseAPNG; var _crc = __nested_webpack_require_1730__(1); var _crc2 = _interopRequireDefault(_crc); var _structs = __nested_webpack_require_1730__(2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var errNotPNG = new Error('Not a PNG'); var errNotAPNG = new Error('Not an animated PNG'); function isNotPNG(err) { return err === errNotPNG; } function isNotAPNG(err) { return err === errNotAPNG; } // '\x89PNG\x0d\x0a\x1a\x0a' var PNGSignature = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); /** * Parse APNG data * @param {ArrayBuffer} buffer * @return {APNG|Error} */ function parseAPNG(buffer) { var bytes = new Uint8Array(buffer); if (Array.prototype.some.call(PNGSignature, function (b, i) { return b !== bytes[i]; })) { return errNotPNG; } // fast animation test var isAnimated = false; eachChunk(bytes, function (type) { return !(isAnimated = type === 'acTL'); }); if (!isAnimated) { return errNotAPNG; } var preDataParts = [], postDataParts = []; var headerDataBytes = null, frame = null, frameNumber = 0, apng = new _structs.APNG(); eachChunk(bytes, function (type, bytes, off, length) { var dv = new DataView(bytes.buffer); switch (type) { case 'IHDR': headerDataBytes = bytes.subarray(off + 8, off + 8 + length); apng.width = dv.getUint32(off + 8); apng.height = dv.getUint32(off + 12); break; case 'acTL': apng.numPlays = dv.getUint32(off + 8 + 4); break; case 'fcTL': if (frame) { apng.frames.push(frame); frameNumber++; } frame = new _structs.Frame(); frame.width = dv.getUint32(off + 8 + 4); frame.height = dv.getUint32(off + 8 + 8); frame.left = dv.getUint32(off + 8 + 12); frame.top = dv.getUint32(off + 8 + 16); var delayN = dv.getUint16(off + 8 + 20); var delayD = dv.getUint16(off + 8 + 22); if (delayD === 0) { delayD = 100; } frame.delay = 1000 * delayN / delayD; // https://bugzilla.mozilla.org/show_bug.cgi?id=125137 // https://bugzilla.mozilla.org/show_bug.cgi?id=139677 // https://bugzilla.mozilla.org/show_bug.cgi?id=207059 if (frame.delay <= 10) { frame.delay = 100; } apng.playTime += frame.delay; frame.disposeOp = dv.getUint8(off + 8 + 24); frame.blendOp = dv.getUint8(off + 8 + 25); frame.dataParts = []; if (frameNumber === 0 && frame.disposeOp === 2) { frame.disposeOp = 1; } break; case 'fdAT': if (frame) { frame.dataParts.push(bytes.subarray(off + 8 + 4, off + 8 + length)); } break; case 'IDAT': if (frame) { frame.dataParts.push(bytes.subarray(off + 8, off + 8 + length)); } break; case 'IEND': postDataParts.push(subBuffer(bytes, off, 12 + length)); break; default: preDataParts.push(subBuffer(bytes, off, 12 + length)); } }); if (frame) { apng.frames.push(frame); } if (apng.frames.length == 0) { return errNotAPNG; } var preBlob = new Blob(preDataParts), postBlob = new Blob(postDataParts); apng.frames.forEach(function (frame) { var bb = []; bb.push(PNGSignature); headerDataBytes.set(makeDWordArray(frame.width), 0); headerDataBytes.set(makeDWordArray(frame.height), 4); bb.push(makeChunkBytes('IHDR', headerDataBytes)); bb.push(preBlob); frame.dataParts.forEach(function (p) { return bb.push(makeChunkBytes('IDAT', p)); }); bb.push(postBlob); frame.imageData = new Blob(bb, { 'type': 'image/png' }); delete frame.dataParts; bb = null; }); return apng; } /** * @param {Uint8Array} bytes * @param {function(string, Uint8Array, int, int): boolean} callback */ function eachChunk(bytes, callback) { var dv = new DataView(bytes.buffer); var off = 8, type = void 0, length = void 0, res = void 0; do { length = dv.getUint32(off); type = readString(bytes, off + 4, 4); res = callback(type, bytes, off, length); off += 12 + length; } while (res !== false && type != 'IEND' && off < bytes.length); } /** * * @param {Uint8Array} bytes * @param {number} off * @param {number} length * @return {string} */ function readString(bytes, off, length) { var chars = Array.prototype.slice.call(bytes.subarray(off, off + length)); return String.fromCharCode.apply(String, chars); } /** * * @param {string} x * @return {Uint8Array} */ function makeStringArray(x) { var res = new Uint8Array(x.length); for (var i = 0; i < x.length; i++) { res[i] = x.charCodeAt(i); } return res; } /** * @param {Uint8Array} bytes * @param {int} start * @param {int} length * @return {Uint8Array} */ function subBuffer(bytes, start, length) { var a = new Uint8Array(length); a.set(bytes.subarray(start, start + length)); return a; } /** * @param {string} type * @param {Uint8Array} dataBytes * @return {Uint8Array} */ var makeChunkBytes = function makeChunkBytes(type, dataBytes) { var crcLen = type.length + dataBytes.length; var bytes = new Uint8Array(crcLen + 8); var dv = new DataView(bytes.buffer); dv.setUint32(0, dataBytes.length); bytes.set(makeStringArray(type), 4); bytes.set(dataBytes, 8); var crc = (0, _crc2.default)(bytes, 4, crcLen); dv.setUint32(crcLen + 4, crc); return bytes; }; var makeDWordArray = function makeDWordArray(x) { return new Uint8Array([x >>> 24 & 0xff, x >>> 16 & 0xff, x >>> 8 & 0xff, x & 0xff]); }; /***/ }), /* 1 */ /***/ (function(module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = function (bytes) { var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var length = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : bytes.length - start; var crc = -1; for (var _i = start, l = start + length; _i < l; _i++) { crc = crc >>> 8 ^ table[(crc ^ bytes[_i]) & 0xFF]; } return crc ^ -1; }; var table = new Uint32Array(256); for (var i = 0; i < 256; i++) { var c = i; for (var k = 0; k < 8; k++) { c = (c & 1) !== 0 ? 0xEDB88320 ^ c >>> 1 : c >>> 1; } table[i] = c; } /** * * @param {Uint8Array} bytes * @param {number} start * @param {number} length * @return {number} */ /***/ }), /* 2 */ /***/ (function(module, exports, __nested_webpack_require_9403__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Frame = exports.APNG = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _player = __nested_webpack_require_9403__(3); var _player2 = _interopRequireDefault(_player); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @property {number} currFrameNumber * @property {Frame} currFrame * @property {boolean} paused * @property {boolean} ended */ var APNG = exports.APNG = function () { function APNG() { _classCallCheck(this, APNG); this.width = 0; this.height = 0; this.numPlays = 0; this.playTime = 0; this.frames = []; } /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {Frame[]} */ _createClass(APNG, [{ key: 'createImages', /** * * @return {Promise.<*>} */ value: function createImages() { return Promise.all(this.frames.map(function (f) { return f.createImage(); })); } /** * * @param {CanvasRenderingContext2D} context * @param {boolean} autoPlay * @return {Promise.<Player>} */ }, { key: 'getPlayer', value: function getPlayer(context) { var _this = this; var autoPlay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; return this.createImages().then(function () { return new _player2.default(_this, context, autoPlay); }); } }]); return APNG; }(); var Frame = exports.Frame = function () { function Frame() { _classCallCheck(this, Frame); this.left = 0; this.top = 0; this.width = 0; this.height = 0; this.delay = 0; this.disposeOp = 0; this.blendOp = 0; this.imageData = null; this.imageElement = null; } /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {number} */ /** @type {Blob} */ /** @type {HTMLImageElement} */ _createClass(Frame, [{ key: 'createImage', value: function createImage() { var _this2 = this; if (this.imageElement) { return Promise.resolve(); } return new Promise(function (resolve, reject) { var url = URL.createObjectURL(_this2.imageData); _this2.imageElement = document.createElement('img'); _this2.imageElement.onload = function () { URL.revokeObjectURL(url); resolve(); }; _this2.imageElement.onerror = function () { URL.revokeObjectURL(url); _this2.imageElement = null; reject(new Error("Image creation error")); }; _this2.imageElement.src = url; }); } }]); return Frame; }(); /***/ }), /* 3 */ /***/ (function(module, exports, __nested_webpack_require_13509__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _events = __nested_webpack_require_13509__(4); var _events2 = _interopRequireDefault(_events); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var _class = function (_EventEmitter) { _inherits(_class, _EventEmitter); /** * @param {APNG} apng * @param {CanvasRenderingContext2D} context * @param {boolean} autoPlay */ /** @type {number} */ /** @type {boolean} */ /** @type {ImageData} */ /** @type {APNG} */ /** @type {CanvasRenderingContext2D} */ function _class(apng, context, autoPlay) { _classCallCheck(this, _class); var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this)); _this.playbackRate = 1.0; _this._currentFrameNumber = 0; _this._ended = false; _this._paused = true; _this._numPlays = 0; _this._rafId = null; _this._apng = apng; _this.context = context; _this.stop(); if (autoPlay) { _this.play(); } return _this; } /** * * @return {number} */ /** @type {number|null} */ /** @type {boolean} */ /** @type {number} */ /** @type {Frame} */ /** @type {number} */ _createClass(_class, [{ key: 'renderNextFrame', value: function renderNextFrame() { this._currentFrameNumber = (this._currentFrameNumber + 1) % this._apng.frames.length; if (this._currentFrameNumber === this._apng.frames.length - 1) { this._numPlays++; if (this._apng.numPlays !== 0 && this._numPlays >= this._apng.numPlays) { this._ended = true; this._paused = true; } } if (this._prevFrame && this._prevFrame.disposeOp == 1) { this.context.clearRect(this._prevFrame.left, this._prevFrame.top, this._prevFrame.width, this._prevFrame.height); } else if (this._prevFrame && this._prevFrame.disposeOp == 2) { this.context.putImageData(this._prevFrameData, this._prevFrame.left, this._prevFrame.top); } var frame = this.currentFrame; this._prevFrame = frame; this._prevFrameData = null; if (frame.disposeOp == 2) { this._prevFrameData = this.context.getImageData(frame.left, frame.top, frame.width, frame.height); } if (frame.blendOp == 0) { this.context.clearRect(frame.left, frame.top, frame.width, frame.height); } this.context.drawImage(frame.imageElement, frame.left, frame.top); this.emit('frame', this._currentFrameNumber); if (this._ended) { this.emit('end'); } } // playback }, { key: 'play', value: function play() { var _this2 = this; if (this._rafId) { cancelAnimationFrame(this._rafId); } this.emit('play'); if (this._ended) { this.stop(); } this._paused = false; var nextRenderTime = performance.now() + this.currentFrame.delay / this.playbackRate; var tick = function tick(now) { if (_this2._ended || _this2._paused) { return; } if (now >= nextRenderTime) { while (now - nextRenderTime >= _this2._apng.playTime / _this2.playbackRate) { nextRenderTime += _this2._apng.playTime / _this2.playbackRate; _this2._numPlays++; } do { _this2.renderNextFrame(); nextRenderTime += _this2.currentFrame.delay / _this2.playbackRate; } while (!_this2._ended && !_this2._paused && now > nextRenderTime); } _this2._rafId = requestAnimationFrame(tick); }; this._rafId = requestAnimationFrame(tick); } }, { key: 'pause', value: function pause() { if (!this._paused) { if (this._rafId) { cancelAnimationFrame(this._rafId); this._rafId = null; } this.emit('pause'); this._paused = true; } } }, { key: 'stop', value: function stop() { if (this._rafId) { cancelAnimationFrame(this._rafId); this._rafId = null; } this.emit('stop'); this._numPlays = 0; this._ended = false; this._paused = true; // render first frame this._currentFrameNumber = -1; this.context.clearRect(0, 0, this._apng.width, this._apng.height); this.renderNextFrame(); } }, { key: 'currentFrameNumber', get: function get() { return this._currentFrameNumber; } /** * * @return {Frame} */ }, { key: 'currentFrame', get: function get() { return this._apng.frames[this._currentFrameNumber]; } }, { key: 'paused', get: function get() { return this._paused; } }, { key: 'ended', get: function get() { return this._ended; } }]); return _class; }(_events2.default); exports.default = _class; /***/ }), /* 4 */ /***/ (function(module, exports) { // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. function EventEmitter() { this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } module.exports = EventEmitter; // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; EventEmitter.prototype._events = undefined; EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. EventEmitter.defaultMaxListeners = 10; // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function(n) { if (!isNumber(n) || n < 0 || isNaN(n)) throw TypeError('n must be a positive number'); this._maxListeners = n; return this; }; EventEmitter.prototype.emit = function(type) { var er, handler, len, args, i, listeners; if (!this._events) this._events = {}; // If there is no 'error' event listener then throw. if (type === 'error') { if (!this._events.error || (isObject(this._events.error) && !this._events.error.length)) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event } else { // At least give some kind of context to the user var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); err.context = er; throw err; } } } handler = this._events[type]; if (isUndefined(handler)) return false; if (isFunction(handler)) { switch (arguments.length) { // fast cases case 1: handler.call(this); break; case 2: handler.call(this, arguments[1]); break; case 3: handler.call(this, arguments[1], arguments[2]); break; // slower default: args = Array.prototype.slice.call(arguments, 1); handler.apply(this, args); } } else if (isObject(handler)) { args = Array.prototype.slice.call(arguments, 1); listeners = handler.slice(); len = listeners.length; for (i = 0; i < len; i++) listeners[i].apply(this, args); } return true; }; EventEmitter.prototype.addListener = function(type, listener) { var m; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events) this._events = {}; // To avoid recursion in the case that type === "newListener"! Before // adding it to the listeners, first emit "newListener". if (this._events.newListener) this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener); if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. this._events[type] = listener; else if (isObject(this._events[type])) // If we've already got an array, just append. this._events[type].push(listener); else // Adding the second element, need to change to array. this._events[type] = [this._events[type], listener]; // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { m = EventEmitter.defaultMaxListeners; } if (m && m > 0 && this._events[type].length > m) { this._events[type].warned = true; console.error('(node) warning: possible EventEmitter memory ' + 'leak detected. %d listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.', this._events[type].length); if (typeof console.trace === 'function') { // not supported in IE 10 console.trace(); } } } return this; }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.once = function(type, listener) { if (!isFunction(listener)) throw TypeError('listener must be a function'); var fired = false; function g() { this.removeListener(type, g); if (!fired) { fired = true; listener.apply(this, arguments); } } g.listener = listener; this.on(type, g); return this; }; // emits a 'removeListener' event iff the listener was removed EventEmitter.prototype.removeListener = function(type, listener) { var list, position, length, i; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events || !this._events[type]) return this; list = this._events[type]; length = list.length; position = -1; if (list === listener || (isFunction(list.listener) && list.listener === listener)) { delete this._events[type]; if (this._events.removeListener) this.emit('removeListener', type, listener); } else if (isObject(list)) { for (i = length; i-- > 0;) { if (list[i] === listener || (list[i].listener && list[i].listener === listener)) { position = i; break; } } if (position < 0) return this; if (list.length === 1) { list.length = 0; delete this._events[type]; } else { list.splice(position, 1); } if (this._events.removeListener) this.emit('removeListener', type, listener); } return this; }; EventEmitter.prototype.removeAllListeners = function(type) { var key, listeners; if (!this._events) return this; // not listening for removeListener, no need to emit if (!this._events.removeListener) { if (arguments.length === 0) this._events = {}; else if (this._events[type]) delete this._events[type]; return this; } // emit removeListener for all listeners on all events if (arguments.length === 0) { for (key in this._events) { if (key === 'removeListener') continue; this.removeAllListeners(key); } this.removeAllListeners('removeListener'); this._events = {}; return this; } listeners = this._events[type]; if (isFunction(listeners)) { this.removeListener(type, listeners); } else if (listeners) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); } delete this._events[type]; return this; }; EventEmitter.prototype.listeners = function(type) { var ret; if (!this._events || !this._events[type]) ret = []; else if (isFunction(this._events[type])) ret = [this._events[type]]; else ret = this._events[type].slice(); return ret; }; EventEmitter.prototype.listenerCount = function(type) { if (this._events) { var evlistener = this._events[type]; if (isFunction(evlistener)) return 1; else if (evlistener) return evlistener.length; } return 0; }; EventEmitter.listenerCount = function(emitter, type) { return emitter.listenerCount(type); }; function isFunction(arg) { return typeof arg === 'function'; } function isNumber(arg) { return typeof arg === 'number'; } function isObject(arg) { return typeof arg === 'object' && arg !== null; } function isUndefined(arg) { return arg === void 0; } /***/ }) /******/ ]) }); ; /***/ }, /***/ 797 (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { A: () => (/* binding */ Rendering_X3DGeometryNode) }); // EXTERNAL MODULE: ./src/x_ite/Fields.js + 15 modules var Fields = __webpack_require__(8015); // EXTERNAL MODULE: ./src/x_ite/Rendering/VertexArray.js var VertexArray = __webpack_require__(3819); // EXTERNAL MODULE: ./src/x_ite/Components/Core/X3DNode.js var X3DNode = __webpack_require__(8001); // EXTERNAL MODULE: ./src/x_ite/Base/X3DConstants.js var X3DConstants = __webpack_require__(5053); // EXTERNAL MODULE: ./src/x_ite/Base/X3DCast.js var X3DCast = __webpack_require__(937); // EXTERNAL MODULE: ./src/x_ite/Browser/Networking/URLs.js var URLs = __webpack_require__(7261); // EXTERNAL MODULE: ./src/x_ite/Namespace.js var Namespace = __webpack_require__(2696); ;// ./src/x_ite/Browser/Rendering/MikkTSpace.js // See: https://github.com/donmccurdy/mikktspace-wasm const __default__ = new class MikkTSpace { #promise; async initialize () { return this .#promise = this .#promise ?? new Promise (async resolve => { const imports = { wbg: { __wbindgen_string_new: (arg0, arg1) => { const ret = this .#getStringFromWasm0 (arg0, arg1); return this .#addHeapObject (ret); }, __wbindgen_rethrow: (arg0) => { throw this .#takeObject (arg0); }, }, }; const input = await fetch (URLs/* default */.A .getLibraryURL ("mikktspace_bg.wasm")); const { instance } = await this .#load (input, imports); this .#wasm = instance .exports; resolve (); }); } isInitialized () { return !! this .#wasm; } async #load (response, imports) { if (typeof WebAssembly .instantiateStreaming === "function") { try { return await WebAssembly .instantiateStreaming (response, imports); } catch (error) { if (response .headers .get ("Content-Type") !== "application/wasm") { // console .warn ("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", error); } else { throw error; } } } const bytes = await response .arrayBuffer (); return await WebAssembly .instantiate (bytes, imports); } /** * Generates vertex tangents for the given position/normal/texcoord attributes. * @param {Float32Array} position vec3 * @param {Float32Array} normal vec3 * @param {Float32Array} texcoord vec2 * @returns {Float32Array} vec4 */ generateTangents (position, normal, texcoord) { try { const retptr = this .#wasm .__wbindgen_add_to_stack_pointer (-16), ptr0 = this .#passArrayF32ToWasm0 (position, this .#wasm .__wbindgen_malloc), len0 = this .#WASM_VECTOR_LEN, ptr1 = this .#passArrayF32ToWasm0 (normal, this .#wasm .__wbindgen_malloc), len1 = this .#WASM_VECTOR_LEN, ptr2 = this .#passArrayF32ToWasm0 (texcoord, this .#wasm .__wbindgen_malloc), len2 = this .#WASM_VECTOR_LEN; this .#wasm .generateTangents (retptr, ptr0, len0, ptr1, len1, ptr2, len2); const r0 = this .#getInt32Memory0 () [retptr / 4 + 0], r1 = this .#getInt32Memory0 () [retptr / 4 + 1], v3 = this .#getArrayF32FromWasm0 (r0, r1) .slice (); this .#wasm .__wbindgen_free (r0, r1 * 4); return v3; } finally { this .#wasm .__wbindgen_add_to_stack_pointer (16); } } #wasm; #textDecoder = new TextDecoder ("utf-8", { ignoreBOM: true, fatal: true }); #uint8Memory0; #getUint8Memory0 () { if (this .#uint8Memory0 ?.buffer !== this .#wasm .memory .buffer) this .#uint8Memory0 = new Uint8Array (this .#wasm .memory .buffer); return this .#uint8Memory0; } #getStringFromWasm0 (ptr, len) { return this .#textDecoder .decode (this .#getUint8Memory0 () .subarray (ptr, ptr + len)); } #heap = Array .from ({ length: 32 }) .concat ([undefined, null, true, false]); #heap_next = this .#heap .length; #addHeapObject (obj) { if (this .#heap_next === this .#heap .length) this .#heap .push (this .#heap .length + 1); const i = this .#heap_next; this .#heap_next = this .#heap [i]; this .#heap [i] = obj; return i; } #getObject (i) { return this .#heap [i]; } #dropObject (i) { if (i < 36) return; this .#heap [i] = this .#heap_next; this .#heap_next = i; } #takeObject (i) { const ret = this .#getObject (i); this .#dropObject (i); return ret; } #float32Memory0; #getFloat32Memory0 () { if (this .#float32Memory0 ?.buffer !== this .#wasm .memory .buffer) this .#float32Memory0 = new Float32Array (this .#wasm .memory .buffer); return this .#float32Memory0; } #WASM_VECTOR_LEN = 0; #passArrayF32ToWasm0 (arg, malloc) { const ptr = malloc (arg .length * 4); this .#getFloat32Memory0 () .set (arg, ptr / 4); this .#WASM_VECTOR_LEN = arg .length; return ptr; } #int32Memory0; #getInt32Memory0 () { if (this .#int32Memory0 ?.buffer !== this .#wasm .memory .buffer) this .#int32Memory0 = new Int32Array (this .#wasm .memory .buffer); return this .#int32Memory0; } #getArrayF32FromWasm0 (ptr, len) { return this .#getFloat32Memory0 () .subarray (ptr / 4, ptr / 4 + len); } }; ; /* harmony default export */ const MikkTSpace = (Namespace/* default */.A .add ("MikkTSpace", __default__)); // EXTERNAL MODULE: ./src/standard/Math/Numbers/Vector3.js var Vector3 = __webpack_require__(477); // EXTERNAL MODULE: ./src/standard/Math/Numbers/Vector4.js var Vector4 = __webpack_require__(8392); // EXTERNAL MODULE: ./src/standard/Math/Numbers/Matrix4.js var Matrix4 = __webpack_require__(9582); // EXTERNAL MODULE: ./src/standard/Math/Geometry/Box3.js var Box3 = __webpack_require__(5687); // EXTERNAL MODULE: ./src/standard/Math/Geometry/Plane3.js var Plane3 = __webpack_require__(1522); // EXTERNAL MODULE: ./src/standard/Math/Algorithm.js var Algorithm = __webpack_require__(5185); // EXTERNAL MODULE: ./src/x_ite/DEVELOPMENT.js var DEVELOPMENT = __webpack_require__(2514); ;// ./src/x_ite/Components/Rendering/X3DGeometryNode.js // Box normals for bbox / line intersection. const boxNormals = [ Vector3/* default */.A .Z_AXIS, // front Vector3/* default */.A .NEGATIVE_Z_AXIS, // back Vector3/* default */.A .Y_AXIS, // top Vector3/* default */.A .NEGATIVE_Y_AXIS, // bottom Vector3/* default */.A .X_AXIS, // right // left: We do not need to test for left. ]; function X3DGeometryNode (executionContext) { X3DNode/* default */.A .call (this, executionContext); this .addType (X3DConstants/* default */.A .X3DGeometryNode); this .addChildObjects (X3DConstants/* default */.A .outputOnly, "transparent", new Fields/* default */.A .SFBool (), X3DConstants/* default */.A .outputOnly, "bbox_changed", new Fields/* default */.A .SFTime (), X3DConstants/* default */.A .outputOnly, "rebuild", new Fields/* default */.A .SFTime (Date .now () / 1000)); // Members this .min = new Vector3/* default */.A (); this .max = new Vector3/* default */.A (); this .bbox = Box3/* default */.A .Extents (this .min, this .max); this .solid = true; this .geometryType = 3; this .colorMaterial = false; this .attribNodes = [ ]; this .attribArrays = [ ]; this .textureCoordinateMapping = new Map (); this .multiTexCoords = [ ]; this .coordIndices = X3DGeometryNode .createArray (); this .texCoords = X3DGeometryNode .createArray (); this .fogDepths = X3DGeometryNode .createArray (); this .colors = X3DGeometryNode .createArray (); this .tangents = X3DGeometryNode .createArray (); this .normals = X3DGeometryNode .createArray (); this .vertices = X3DGeometryNode .createArray (); this .hasFogCoords = false; this .hasNormals = false; this .geometryKey = ""; this .vertexCount = 0; this .planes = [ ]; for (let i = 0; i < 5; ++ i) this .planes [i] = new Plane3/* default */.A (); } class GeometryArray extends Array { #typedArray = new Float32Array (); assign (value) { const length = value .length; this .length = length; for (let i = 0; i < length; ++ i) this [i] = value [i]; } getValue () { return this .#typedArray; } shrinkToFit () { if (this .length === this .#typedArray .length) this .#typedArray .set (this); else this .#typedArray = new Float32Array (this); return this .#typedArray; } } Object .defineProperty (X3DGeometryNode, "createArray", { // Function to select ether Array or MFFloat for color/normal/vertex arrays. // Array version runs faster, see BeyondGermany and TreasureIsland. value () { // return new Fields .MFFloat (); return new GeometryArray (); }, }) Object .assign (Object .setPrototypeOf (X3DGeometryNode .prototype, X3DNode/* default */.A .prototype), { setup () { X3DNode/* default */.A .prototype .setup .call (this); this .rebuild (); }, initialize () { X3DNode/* default */.A .prototype .initialize .call (this); const browser = this .getBrowser (), gl = browser .getContext (); this .getLive () .addInterest ("set_live__", this); this .addInterest ("requestRebuild", this); this ._rebuild .addInterest ("rebuild", this); this .coordIndexBuffer = gl .createBuffer (); this .attribBuffers = [ ]; this .textureCoordinateNode = browser .getDefaultTextureCoordinate (); this .texCoordBuffers = Array .from ({length: browser .getMaxTexCoords ()}, () => gl .createBuffer ()); this .fogDepthBuffer = gl .createBuffer (); this .colorBuffer = gl .createBuffer (); this .tangentBuffer = gl .createBuffer (); this .normalBuffer = gl .createBuffer (); this .vertexBuffer = gl .createBuffer (); this .vertexArrayObject = new VertexArray/* default */.A (gl); this .setCCW (true); this .set_live__ (); }, getGeometryType () { return this .geometryType; }, setGeometryType (value) { this .geometryType = value; }, setTransparent (value) { if (!!value !== this ._transparent .getValue ()) this ._transparent = value; }, isTransparent () { return this ._transparent .getValue (); }, getBBox () { // With