From 5c9b04667533b08f3f54b13e3fe4cb581f7d8861 Mon Sep 17 00:00:00 2001 From: Keith Clark Date: Tue, 4 Jun 2019 23:53:40 +0100 Subject: [PATCH] Update dist files --- dist/model-element.js | 209 +++++++++++++++++++++++++++----------- dist/model-element.js.map | 2 +- dist/model-element.min.js | 4 +- 3 files changed, 152 insertions(+), 63 deletions(-) diff --git a/dist/model-element.js b/dist/model-element.js index 153a827..0f0d4a9 100644 --- a/dist/model-element.js +++ b/dist/model-element.js @@ -1,12 +1,8 @@ +//! 3D Model Element v1.0.2 | (C) Keith Clark | MIT | https://github.com/keithclark/3d-model-element + (function () { 'use strict'; - /* While mapping objects to a DOM element, it's useful to have a bounding box - to reference. Enabling this flag will produce just that, a 2D bounding rect - that should match the related DOM element */ - const RENDER_OBJECT_BOUNDING_BOX = false; - - const normalize = obj => { let box = new THREE.Box3().setFromObject(obj); let size = new THREE.Vector3(); @@ -15,36 +11,21 @@ let scale = 1 / Math.max(size.x, size.y); obj.position.multiplyScalar(-scale); - obj.scale.set(scale, scale, scale); + obj.scale.multiplyScalar(scale); + obj.userData.size = size.multiplyScalar(scale).clone(); return obj; }; - const createDebugBoundingBox = obj => { - let material = new THREE.LineBasicMaterial({color: 0x00ff00}); - let geometry = new THREE.PlaneGeometry(1, 1); - let wireframe = new THREE.WireframeGeometry(geometry); - let boundingBox = new THREE.LineSegments(wireframe, material); - return boundingBox; - }; - - const createContainer = obj => { let container = new THREE.Object3D(); - - if (RENDER_OBJECT_BOUNDING_BOX) { - container.add(createDebugBoundingBox()); - } - container.add(obj); - return container; }; var modelUtils = { normalize, - createDebugBoundingBox, createContainer }; @@ -60,7 +41,7 @@ var urlUtils = { getFileExtension - } + }; const loaders = {}; @@ -175,7 +156,7 @@ /** * Resolves and returns the transform and perspective properties for a given - * element. + * element. */ const getTransformForElement = elem => { @@ -188,13 +169,7 @@ let posX = 0; let posY = 0; - // if this element doesn't have a width or height bail out now. - if (elem.offsetWidth === 0 || elem.offsetHeight === 0) { - return m1; - } - posX -= elem.offsetWidth / 2; - posY += elem.offsetHeight / 2; // We need to apply transforms from the root so we walk up the DOM tree, // pushing each node onto a stack. While we're walking to the DOM we also @@ -218,7 +193,6 @@ while (elem = stack.pop()) { let style = getComputedStyle(elem); - cssUtils.parseOriginValue(style.transformOrigin, transformOrigin); cssUtils.parseTransformValue(style.transform, transformMatrix); @@ -405,12 +379,13 @@ let transformMatrix; let clipHeight; let clipWidth; - let width = elem.offsetWidth; - - // If the elements width is `0`, bail out early. - if (width === 0) { - return; - } + let model = child.children[0]; + let boundsElem = elem.shadowRoot.children[1]; + let size = model.userData.size; + let elemWidth = elem.offsetWidth; + let elemHeight = elem.offsetHeight; + let scale = Math.min(elemWidth / size.x, elemHeight / size.y); + let objWidth = size.x * scale; projection = domUtils.getProjectionForElement(elem); clipHeight = projection.clipBounds.bottom - projection.clipBounds.top; @@ -430,12 +405,22 @@ // Objects are normalised so we can scale them up by their width to // render them at the intended size. - child.scale.multiplyScalar(width); + child.scale.multiplyScalar(scale); + + // Now scale the DOM bounding box so it matches the size and shape of the + // model. An `IntersectionObserver` will use this DOM structure to decide + // if this model needs to be rendered at the next animation frame. + let scaleX = size.x * scale; + let scaleY = size.y * scale; + let scaleZ = size.z * scale; + boundsElem.style.transform = `translate(-50%,-50%)scale3d(${scaleX},${scaleY},${scaleZ})`; // Three's coordinate space uses 0,0,0 as the screen centre so we need // to adjust the computed X/Y position back to the top-left of the screen // to match the CSS rendering position. - child.position.x += width - overlayWidth / 2; + child.position.x -= objWidth - elemWidth / 2; + child.position.x += objWidth - overlayWidth / 2; + child.position.y -= elemHeight / 2; child.position.y += overlayHeight / 2; // Determine which camera to use to project this model and set its @@ -457,7 +442,7 @@ // Set the clipping box (scissor) and render the element. renderer.setScissor( projection.clipBounds.left, - projection.clipBounds.top, + overlayHeight - projection.clipBounds.bottom, clipWidth, clipHeight ); @@ -474,11 +459,11 @@ const setOrthographicCamera = (bounds) => { let camera; - + if (!orthographicCamera) { orthographicCamera = new THREE.OrthographicCamera(); - } - + } + camera = orthographicCamera; camera.left = bounds.left - overlayWidth / 2; camera.top = -bounds.top + overlayHeight / 2; @@ -493,7 +478,7 @@ const setPerspectiveCamera = (bounds, perspective, perspectiveOrigin) => { let camera; - + if (!perspectiveCamera) { perspectiveCamera = new THREE.PerspectiveCamera(); } @@ -552,27 +537,93 @@ const objects = new WeakMap(); - const ELEMENT_DEFAULT_STYLES = + + const ATTR_TO_CUSTOM_PROP_MAP = { + 'width': '--xModelWidth', + 'height': '--xModelHeight' + }; + + const CANVAS_DEFAULT_STYLES = + ':root{' + + 'transform-style:flat!important;' + + '}' + '#x-model-renderLayer{' + 'position:fixed;' + 'top:0;' + 'left:0;' + 'pointer-events:none' + - '}' + - 'x-model{' + - 'display:inline-block;' + - 'width:250px;' + - 'height:250px' + '}'; + + const ELEMENT_DEFAULT_STYLES = + ':host{' + + 'display:inline-block;' + + 'width:var(--xModelWidth,200px);' + + 'height:var(--xModelHeight,150px);' + + 'transform-style:var(--xModelBoundingBoxTransformStyle, preserve-3d)' + + '}' + + '.boundingBox{' + + 'visibility:var(--xModelBoundingBoxVisibility, hidden);' + + 'transform-style:inherit;' + + 'position:relative;' + + 'left:50%;' + + 'top:50%;' + + 'width:1px;' + + 'height:1px;' + + 'background:#08c' + + '}' + + '.boundingBox__face{' + + 'position:absolute;' + + 'width:1px;' + + 'height:1px;' + + 'background:#0c0' + + '}' + + '.boundingBox__face:nth-child(1){transform:translateZ(-.5px)}' + + '.boundingBox__face:nth-child(2){transform:translateZ(.5px)}' + + '.boundingBox__face:nth-child(3){transform:translateY(-.5px)rotateX(90deg)}' + + '.boundingBox__face:nth-child(4){transform:translateY(.5px)rotateX(-90deg)}' + + '.boundingBox__face:nth-child(5){transform:translateX(.5px)rotateY(-90deg)}' + + '.boundingBox__face:nth-child(6){transform:translateX(-.5px)rotateY(-90deg)}'; + + + const ELEMENT_HTML = + `` + + '
' + + '
'.repeat(6) + + '
'; + + let styleElem; + let intersectionObserver; + + + const intersectionCallback = entries => { + entries.forEach(entry => { + let obj = objects.get(entry.target.parentElement); + if (entry.isIntersecting) { + if (obj.axisInView < 6) { + if (obj.axisInView === 0) { + modelLayer.add(obj); + } + obj.axisInView++; + } + } else { + if (obj.axisInView > 0) { + obj.axisInView--; + if (obj.axisInView === 0) { + modelLayer.remove(obj); + } + } + } + }); + }; const initModelLayer = () => { // The first time an element is added to the document we inject a // stylesheet that contains its default styles. Ideally this would be // appended to the shadow DOM, but support for that isn't great right now. - styleElem = domUtils.createStylesheet(ELEMENT_DEFAULT_STYLES); + styleElem = domUtils.createStylesheet(CANVAS_DEFAULT_STYLES); let head = document.documentElement.firstChild; head.insertBefore(styleElem, head.firstChild); @@ -582,6 +633,11 @@ let renderDomElement = modelLayer.init(); renderDomElement.setAttribute('id', 'x-model-renderLayer'); document.documentElement.appendChild(renderDomElement); + + // Use an intersection observer to watch for elements entering and leaving + // the viewport + intersectionObserver = new IntersectionObserver(intersectionCallback); + }; @@ -589,35 +645,68 @@ constructor() { super(); + // Create six child elements. These will be rotated and translated along the + // X Y and Z axis to create a bounding box around the model. These + // elements will be monitored by an `IntersectionObserver` which will add + // the model to the scene if the any elements are visible in the viewport + // and remove the model when no elements are visible + this.attachShadow({mode: 'open'}); + this.shadowRoot.innerHTML = ELEMENT_HTML; } static get observedAttributes() { - return ['src']; + return ['src', 'width', 'height']; } connectedCallback() { if (!styleElem) { initModelLayer(); } - let obj = objects.get(this); if (obj && obj.elem !== this) { + let model = obj.children[0]; + let size = model.userData.size; + let scale = Math.min(this.offsetWidth / size.x, this.offsetHeight / size.y); + let scaleX = size.x * scale; + let scaleY = size.y * scale; + let scaleZ = size.z * scale; + + // Scale and distort the DOM bounding box (a cube) along X, Y and Z axis + // so it matches the size and shape of the models bounding box. + let box = this.shadowRoot.querySelector('.boundingBox'); + box.style.transform = `translate(-50%,-50%)scale3d(${scaleX},${scaleY},${scaleZ})`; + + // Monitor each face with an `IntersectionObserver` so we can determine if + // the model is visible in the viewport when it's rendered with + // perspective projection. + let faces = Array.from(box.children); + faces.forEach(elem => intersectionObserver.observe(elem)); + obj.elem = this; - modelLayer.add(obj); + obj.axisInView = 0; + + objects.set(box, obj); } } disconnectedCallback() { let obj = objects.get(this); if (obj && obj.elem === this) { - modelLayer.remove(obj); + let box = this.shadowRoot.querySelector('.boundingBox'); + let faces = Array.from(box.children); + faces.forEach(elem => intersectionObserver.unobserve(elem)); obj.elem = null; } } attributeChangedCallback(attribute, oldValue, newValue) { - if (attribute === 'src') { - + if (attribute === 'width' || attribute === 'height') { + if (newValue !== null) { + newValue += 'px'; + } + let customProp = ATTR_TO_CUSTOM_PROP_MAP[attribute]; + this.shadowRoot.children[0].sheet.rules[0].style.setProperty(customProp, newValue); + } else if (attribute === 'src') { // call the disconnected callback handler to release the current model if // one is attached this.disconnectedCallback(); @@ -658,7 +747,7 @@ return loader.load(src, loadHandler, null, errorHandler); }); - } + }; let loader$1; @@ -682,7 +771,7 @@ return loader$1.load(src, loadHandler, null, errorHandler); }); - } + }; if ('customElements' in window) { diff --git a/dist/model-element.js.map b/dist/model-element.js.map index d8196a2..421036b 100644 --- a/dist/model-element.js.map +++ b/dist/model-element.js.map @@ -1 +1 @@ -{"version":3,"file":"model-element.js","sources":["../src/utils/model.js","../src/utils/url.js","../src/modelLoader.js","../src/utils/css.js","../src/utils/dom.js","../src/modelLayer.js","../src/modelElement.js","../src/loaders/gltf.js","../src/loaders/obj.js","../src/index.js"],"sourcesContent":["/* While mapping objects to a DOM element, it's useful to have a bounding box\nto reference. Enabling this flag will produce just that, a 2D bounding rect\nthat should match the related DOM element */\nconst RENDER_OBJECT_BOUNDING_BOX = false;\n\n\nconst normalize = obj => {\n let box = new THREE.Box3().setFromObject(obj);\n let size = new THREE.Vector3();\n box.getCenter(obj.position);\n box.getSize(size);\n\n let scale = 1 / Math.max(size.x, size.y);\n obj.position.multiplyScalar(-scale);\n obj.scale.set(scale, scale, scale);\n return obj;\n};\n\n\nconst createDebugBoundingBox = obj => {\n let material = new THREE.LineBasicMaterial({color: 0x00ff00});\n let geometry = new THREE.PlaneGeometry(1, 1);\n let wireframe = new THREE.WireframeGeometry(geometry);\n let boundingBox = new THREE.LineSegments(wireframe, material);\n return boundingBox;\n};\n\n\nconst createContainer = obj => {\n let container = new THREE.Object3D();\n\n if (RENDER_OBJECT_BOUNDING_BOX) {\n container.add(createDebugBoundingBox());\n }\n\n container.add(obj);\n\n return container;\n};\n\n\nexport default {\n normalize,\n createDebugBoundingBox,\n createContainer\n};\n","\nconst getFileExtension = url => {\n let path = url.split(/[?#]/)[0];\n let segments = path.split('/');\n let filename = segments.pop();\n let ext = filename.split('.');\n if (ext.length > 0) {\n return '.' + ext.pop();\n }\n}\n\nexport default {\n getFileExtension\n}","import modelUtils from './utils/model';\nimport urlUtils from './utils/url';\n\n\nconst loaders = {};\n\n\nconst register = (ext, handler) => {\n loaders[ext] = {\n load: handler,\n objectCache: {}\n };\n};\n\n\nconst load = src => {\n let loader;\n let object;\n let ext = urlUtils.getFileExtension(src);\n\n if (ext) {\n loader = loaders[ext];\n }\n\n if (!loader) {\n console.error(`Couldn't load \"${src}\". Unknown object format \"${ext}\"`);\n return Promise.reject();\n }\n\n object = loader.objectCache[src];\n if (!object) {\n object = loader.load(src).then(obj => {\n // To help make sizing easier to deal with we normalize the models \n // dimenstions so its maximum width / height is 1. When rendering the\n // object we can scale it up by the width of the target DOM element.\n modelUtils.normalize(obj);\n\n // Finally the model is inserted into a container.\n return modelUtils.createContainer(obj);\n });\n loader.objectCache[src] = object;\n }\n \n return object.then(model => model.clone());\n};\n\n\nexport default {\n load,\n register\n};\n","/**\n * Strips the unit from a value (i.e. 100.55px) and converts the remaining\n * value to a number.\n */\nconst parseUnitValue = value => {\n return parseFloat(value || 0);\n};\n\n\n/**\n * Parses a CSS origin string (`perspective-origin`, `transform-origin`) into\n * it's X, Y and Z components and populates the supplied THREE.Vector3 with\n * the result.\n */\nconst parseOriginValue = (originString, vec3) => {\n let transformOrigin = originString.split(' ');\n vec3.set(\n parseUnitValue(transformOrigin[0]),\n parseUnitValue(transformOrigin[1]),\n parseUnitValue(transformOrigin[2])\n );\n};\n\n\n/**\n * Parses a CSS 3x2 matrix() or 4x4 matrix3d() string into its compontents and \n * populates the passed THREE.Matrix4 with the result.\n * \n * (https://keithclark.co.uk/articles/calculating-element-vertex-data-from-css-transforms/)\n */\n\nconst parseTransformValue = (matrixString, mat4) => {\n var c = matrixString.split(/\\s*[(),]\\s*/).slice(1, -1);\n\n if (c.length === 6) {\n // 'matrix()' (3x2)\n mat4.set(\n +c[0], -c[2], 0, +c[4],\n -c[1], +c[3], 0, -c[5],\n 0, 0, 1, 0,\n 0, 0, 0, 1\n );\n } else if (c.length === 16) {\n // matrix3d() (4x4)\n mat4.set(\n +c[0], -c[4], +c[8], +c[12],\n -c[1], +c[5], -c[9], -c[13],\n +c[2], -c[6], +c[10], +c[14],\n +c[3], +c[7], +c[11], +c[15]\n );\n } else {\n // handle 'none' or invalid values.\n mat4.identity();\n }\n};\n\n\nexport default {\n parseTransformValue,\n parseOriginValue,\n parseUnitValue\n};\n","import cssUtils from './css';\n\n/**\n * Resolves and returns the transform and perspective properties for a given\n * element. \n */\n\nconst getTransformForElement = elem => {\n let m1 = new THREE.Matrix4();\n let transformMatrix = new THREE.Matrix4();\n let transformOrigin = new THREE.Vector3();\n let transformOriginMatrix = new THREE.Matrix4();\n let osParent = elem;\n let stack = [];\n let posX = 0;\n let posY = 0;\n\n // if this element doesn't have a width or height bail out now.\n if (elem.offsetWidth === 0 || elem.offsetHeight === 0) {\n return m1;\n }\n\n posX -= elem.offsetWidth / 2;\n posY += elem.offsetHeight / 2;\n\n // We need to apply transforms from the root so we walk up the DOM tree,\n // pushing each node onto a stack. While we're walking to the DOM we also\n // resolve the elements X/Y position.\n while (elem) {\n if (elem === osParent) {\n posX += elem.offsetLeft;\n posY += elem.offsetTop;\n osParent = elem.offsetParent;\n }\n stack.push(elem);\n posX -= elem.scrollLeft;\n posY -= elem.scrollTop;\n elem = elem.parentElement;\n }\n\n\n m1.makeTranslation(posX, -posY, 0);\n\n // Now we can resolve transforms.\n while (elem = stack.pop()) {\n\n let style = getComputedStyle(elem);\n\n cssUtils.parseOriginValue(style.transformOrigin, transformOrigin);\n cssUtils.parseTransformValue(style.transform, transformMatrix);\n\n let ox = transformOrigin.x - elem.offsetWidth / 2;\n let oy = transformOrigin.y - elem.offsetHeight / 2;\n let oz = transformOrigin.z;\n\n // If the computed `transform-origin` is a value other than `50% 50% 0`\n // (`0,0,0` in THREE coordinate space) then we need to translate by the\n // origin before multiplying the element's transform matrix. Finally, we\n // need undo the translation.\n if (ox !== 0 || oy !== 0 || oz !== 0) {\n m1.multiply(transformOriginMatrix.makeTranslation(ox, -oy, oz));\n m1.multiply(transformMatrix);\n m1.multiply(transformOriginMatrix.makeTranslation(-ox, oy, -oz));\n } else {\n m1.multiply(transformMatrix);\n }\n }\n\n return m1;\n};\n\n\nconst getProjectionForElement = elem => {\n let perspectiveOrigin = new THREE.Vector3();\n let perspective;\n let clipBounds = {\n left: 0,\n top: 0,\n right: innerWidth,\n bottom: innerHeight\n };\n let cameraBounds = {\n left: 0,\n top: 0,\n right: innerWidth,\n bottom: innerHeight\n };\n\n\n while (elem) {\n let style = getComputedStyle(elem);\n let elemBounds = elem.getBoundingClientRect();\n\n // TODO: It's possible to nest perspectives. Need to research the impact\n // of this and, if possible, how to emulate it. For now, we'll just use\n // the last value found.\n let perspectiveValue = style.perspective;\n if (!perspective) {\n if (perspectiveValue !== 'none') {\n perspective = cssUtils.parseUnitValue(perspectiveValue);\n\n cameraBounds.top = elemBounds.top;\n cameraBounds.left = elemBounds.left;\n cameraBounds.right = elemBounds.right;\n cameraBounds.bottom = elemBounds.bottom;\n\n // TODO: strictly speaking, `perspective-origin` can be set on any\n // element, not just the one that has `perspective`. Research the impact\n // of setting perspective-origin on different elements in the DOM tree.\n let perspectiveOriginValue = style.perspectiveOrigin;\n if (perspectiveOriginValue) {\n cssUtils.parseOriginValue(perspectiveOriginValue, perspectiveOrigin);\n }\n }\n }\n\n\n if (style.overflow !== 'visible') {\n clipBounds.top = Math.max(elemBounds.top, clipBounds.top);\n clipBounds.left = Math.max(elemBounds.left, clipBounds.left);\n clipBounds.right = Math.min(elemBounds.right, clipBounds.right);\n clipBounds.bottom = Math.min(elemBounds.bottom, clipBounds.bottom);\n }\n\n elem = elem.parentElement;\n\n }\n\n return {\n perspective: perspective,\n perspectiveOrigin: perspectiveOrigin,\n clipBounds: clipBounds,\n cameraBounds: cameraBounds\n };\n};\n\n\n\nconst createStylesheet = cssText => {\n let styleElem = document.createElement('style');\n styleElem.textContent = cssText;\n return styleElem;\n};\n\n\n\nexport default {\n getTransformForElement,\n getProjectionForElement,\n createStylesheet\n};\n","import domUtils from './utils/dom';\n\nlet perspective;\nlet camera;\nlet overlayWidth;\nlet overlayHeight;\nlet perspectiveCamera;\nlet orthographicCamera;\nlet renderer;\nlet scene;\nlet light;\n\nconst objs = [];\n\n\nconst init = () => {\n if (scene) {\n return false;\n }\n\n // create the scene\n scene = new THREE.Scene();\n\n // add a light\n light = new THREE.PointLight(0x808080, 2, 0);\n light.position.set(0, 0, 0);\n scene.add(light);\n\n /*\n var sphereSize = .5;\n var pointLightHelper = new THREE.PointLightHelper( light, sphereSize, 0xff00ff );\n scene.add( pointLightHelper );\n */\n\n // create the WebGL renderer\n renderer = new THREE.WebGLRenderer({\n antialias: true,\n alpha: true\n });\n\n renderer.setScissorTest(true);\n renderer.setClearColor(0x000000, 0);\n renderer.autoClear = false;\n renderer.sortObjects = false;\n requestAnimationFrame(render);\n\n return renderer.domElement;\n};\n\n\nconst add = obj => {\n let index = objs.indexOf(obj);\n if (index === -1) {\n objs.push(obj);\n return true;\n }\n return false;\n};\n\n\nconst remove = (obj) => {\n let index = objs.indexOf(obj);\n if (index > -1) {\n objs.splice(index, 1);\n return true;\n }\n return false;\n};\n\n\nconst update = () => {\n overlayWidth = window.innerWidth;\n overlayHeight = window.innerHeight;\n camera = null;\n renderer.setSize(overlayWidth, overlayHeight);\n renderer.clear();\n\n // Walk over each object and update it\n objs.forEach(child => {\n let elem = child.elem;\n if (elem) {\n let projection;\n let transformMatrix;\n let clipHeight;\n let clipWidth;\n let width = elem.offsetWidth;\n\n // If the elements width is `0`, bail out early.\n if (width === 0) {\n return;\n }\n\n projection = domUtils.getProjectionForElement(elem);\n clipHeight = projection.clipBounds.bottom - projection.clipBounds.top;\n clipWidth = projection.clipBounds.right - projection.clipBounds.left;\n\n // If the elements clip area has a height or width of `0`, bail out early.\n if (clipWidth <= 0 || clipHeight <= 0) {\n return;\n }\n\n transformMatrix = domUtils.getTransformForElement(elem);\n\n // Apply the transform matrix of the DOM node to the model\n child.rotation.setFromRotationMatrix(transformMatrix);\n child.position.setFromMatrixPosition(transformMatrix);\n child.scale.setFromMatrixScale(transformMatrix);\n\n // Objects are normalised so we can scale them up by their width to\n // render them at the intended size.\n child.scale.multiplyScalar(width);\n\n // Three's coordinate space uses 0,0,0 as the screen centre so we need\n // to adjust the computed X/Y position back to the top-left of the screen\n // to match the CSS rendering position.\n child.position.x += width - overlayWidth / 2;\n child.position.y += overlayHeight / 2;\n\n // Determine which camera to use to project this model and set its\n // properties prior to rendering\n if (projection.perspective) {\n camera = setPerspectiveCamera(\n projection.cameraBounds,\n projection.perspective,\n projection.perspectiveOrigin\n );\n } else {\n camera = setOrthographicCamera(projection.cameraBounds);\n }\n\n light.position.x = projection.cameraBounds.left + (projection.cameraBounds.right - projection.cameraBounds.left) / 2 - overlayWidth / 2;\n light.position.y = overlayHeight / 2 - projection.cameraBounds.top - (projection.cameraBounds.bottom - projection.cameraBounds.top) / 2;\n light.position.z = camera.far;\n\n // Set the clipping box (scissor) and render the element.\n renderer.setScissor(\n projection.clipBounds.left,\n projection.clipBounds.top,\n clipWidth,\n clipHeight\n );\n scene.add(child);\n renderer.render(scene, camera);\n scene.remove(child);\n\n }\n });\n\n return !!camera;\n};\n\n\nconst setOrthographicCamera = (bounds) => {\n let camera;\n \n if (!orthographicCamera) {\n orthographicCamera = new THREE.OrthographicCamera();\n } \n \n camera = orthographicCamera;\n camera.left = bounds.left - overlayWidth / 2;\n camera.top = -bounds.top + overlayHeight / 2;\n camera.bottom = -bounds.bottom + overlayHeight / 2;\n camera.right = bounds.right - overlayWidth / 2;\n camera.near = -700;\n camera.updateProjectionMatrix();\n\n return camera;\n};\n\n\nconst setPerspectiveCamera = (bounds, perspective, perspectiveOrigin) => {\n let camera;\n \n if (!perspectiveCamera) {\n perspectiveCamera = new THREE.PerspectiveCamera();\n }\n\n camera = perspectiveCamera;\n camera.fov = 180 * (2 * Math.atan(overlayHeight / 2 / perspective)) / Math.PI;\n camera.aspect = overlayWidth / overlayHeight;\n camera.position.set(0, 0, perspective);\n camera.updateProjectionMatrix();\n\n // Add perspective-origin\n let originX = overlayWidth / 2 - bounds.left - perspectiveOrigin.x;\n let originY = overlayHeight / 2 - bounds.top - perspectiveOrigin.y;\n\n\n // The default is origin for perspective is `50% 50%`, which equates to\n // `0,0`. If the author hasn't specified a different value we don't need\n // to make any adjustments to the projection matrix\n if (originX !== 0 || originY !== 0) {\n\n // copy the projection matrix\n let tmpMatrix = camera.projectionMatrix.clone();\n\n // set the camera projection matrix to the origin\n camera.projectionMatrix.makeTranslation(\n -originX / (overlayWidth / 2),\n originY / (overlayHeight / 2),\n 0\n );\n\n // apply to original camera projection matrix\n camera.projectionMatrix.multiply(tmpMatrix);\n\n // remove the origin offset\n tmpMatrix.makeTranslation(originX, -originY, 0);\n camera.projectionMatrix.multiply(tmpMatrix);\n\n }\n\n return camera;\n};\n\n\nconst render = () => {\n requestAnimationFrame(render);\n update();\n};\n\n\nexport default {\n init,\n add,\n remove,\n render\n};\n","import modelLoader from './modelLoader';\nimport modelLayer from './modelLayer';\nimport domUtils from './utils/dom';\n\n\nconst objects = new WeakMap();\n\nconst ELEMENT_DEFAULT_STYLES =\n '#x-model-renderLayer{' +\n 'position:fixed;' +\n 'top:0;' +\n 'left:0;' +\n 'pointer-events:none' +\n '}' +\n 'x-model{' +\n 'display:inline-block;' +\n 'width:250px;' +\n 'height:250px' +\n '}';\n\nlet styleElem;\n\n\nconst initModelLayer = () => {\n // The first time an element is added to the document we inject a\n // stylesheet that contains its default styles. Ideally this would be\n // appended to the shadow DOM, but support for that isn't great right now.\n styleElem = domUtils.createStylesheet(ELEMENT_DEFAULT_STYLES);\n let head = document.documentElement.firstChild;\n head.insertBefore(styleElem, head.firstChild);\n\n // Initialize the model layer and append the resulting DOM node to the\n // document root - outside the to prevent perspective or transform\n // styles from affecting it.\n let renderDomElement = modelLayer.init();\n renderDomElement.setAttribute('id', 'x-model-renderLayer');\n document.documentElement.appendChild(renderDomElement);\n};\n\n\nexport default class extends HTMLElement {\n\n constructor() {\n super();\n }\n\n static get observedAttributes() {\n return ['src'];\n }\n\n connectedCallback() {\n if (!styleElem) {\n initModelLayer();\n }\n\n let obj = objects.get(this);\n if (obj && obj.elem !== this) {\n obj.elem = this;\n modelLayer.add(obj);\n }\n }\n\n disconnectedCallback() {\n let obj = objects.get(this);\n if (obj && obj.elem === this) {\n modelLayer.remove(obj);\n obj.elem = null;\n }\n }\n\n attributeChangedCallback(attribute, oldValue, newValue) {\n if (attribute === 'src') {\n\n // call the disconnected callback handler to release the current model if\n // one is attached\n this.disconnectedCallback();\n\n modelLoader.load(newValue).then(obj => {\n let event = new UIEvent('load');\n this.dispatchEvent(event);\n objects.set(this, obj);\n this.connectedCallback();\n }).catch(e => {\n let event = new UIEvent('error');\n this.dispatchEvent(event);\n });\n }\n }\n\n}\n","let loader;\n\n\nexport default src => {\n\n return new Promise((resolve, reject) => {\n\n const loadHandler = gltf => {\n resolve(gltf.scene);\n }\n\n const errorHandler = () => {\n reject();\n }\n\n if (!loader) {\n loader = new THREE.GLTFLoader();\n }\n\n return loader.load(src, loadHandler, null, errorHandler);\n\n });\n}\n","let loader;\n\n\nexport default src => {\n\n return new Promise((resolve, reject) => {\n\n const loadHandler = obj => {\n resolve(obj);\n }\n\n const errorHandler = () => {\n reject();\n }\n\n if (!loader) {\n loader = new THREE.OBJLoader();\n }\n\n return loader.load(src, loadHandler, null, errorHandler);\n\n });\n}\n","import HTMLModelElement from './modelElement.js';\nimport modelLoader from './modelLoader.js';\nimport gltfLoader from './loaders/gltf';\nimport objLoader from './loaders/obj';\n\n\nif ('customElements' in window) {\n\n if (!('THREE' in window)) {\n throw 'THREE (threejs.org) is required.';\n }\n\n if ('GLTFLoader' in THREE) {\n modelLoader.register('.gltf', gltfLoader);\n modelLoader.register('.glb', gltfLoader);\n }\n\n if ('OBJLoader' in THREE) {\n modelLoader.register('.obj', objLoader);\n }\n\n customElements.define('x-model', HTMLModelElement);\n}\n"],"names":["loader"],"mappings":";;;EAAA;EACA;EACA;EACA,MAAM,0BAA0B,GAAG,KAAK,CAAC;;;EAGzC,MAAM,SAAS,GAAG,GAAG,IAAI;EACzB,EAAE,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;EAChD,EAAE,IAAI,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;EACjC,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;EAC9B,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;;EAEpB,EAAE,IAAI,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;EAC3C,EAAE,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC;EACtC,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;EACrC,EAAE,OAAO,GAAG,CAAC;EACb,CAAC,CAAC;;;EAGF,MAAM,sBAAsB,GAAG,GAAG,IAAI;EACtC,EAAE,IAAI,QAAQ,GAAG,IAAI,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GAAG,GAAG,IAAI;EAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;EACnB,MAAK;;EAEL,IAAI,MAAM,YAAY,GAAG,MAAM;EAC/B,MAAM,MAAM,EAAE,CAAC;EACf,MAAK;;EAEL,IAAI,IAAI,CAACA,QAAM,EAAE;EACjB,MAAMA,QAAM,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;EACrC,KAAK;;EAEL,IAAI,OAAOA,QAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;;EAE7D,GAAG,CAAC,CAAC;EACL,CAAC;;EChBD,IAAI,gBAAgB,IAAI,MAAM,EAAE;;EAEhC,EAAE,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC,EAAE;EAC5B,IAAI,MAAM,kCAAkC,CAAC;EAC7C,GAAG;;EAEH,EAAE,IAAI,YAAY,IAAI,KAAK,EAAE;EAC7B,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;EAC9C,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;EAC7C,GAAG;;EAEH,EAAE,IAAI,WAAW,IAAI,KAAK,EAAE;EAC5B,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;EAC5C,GAAG;;EAEH,EAAE,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;EACrD,CAAC;;;;"} \ No newline at end of file +{"version":3,"file":"model-element.js","sources":["../src/utils/model.js","../src/utils/url.js","../src/modelLoader.js","../src/utils/css.js","../src/utils/dom.js","../src/modelLayer.js","../src/modelElement.js","../src/loaders/gltf.js","../src/loaders/obj.js","../src/index.js"],"sourcesContent":["\nconst normalize = obj => {\n let box = new THREE.Box3().setFromObject(obj);\n let size = new THREE.Vector3();\n box.getCenter(obj.position);\n box.getSize(size);\n\n let scale = 1 / Math.max(size.x, size.y);\n obj.position.multiplyScalar(-scale);\n obj.scale.multiplyScalar(scale);\n obj.userData.size = size.multiplyScalar(scale).clone();\n return obj;\n};\n\n\nconst createContainer = obj => {\n let container = new THREE.Object3D();\n container.add(obj);\n return container;\n};\n\n\nexport default {\n normalize,\n createContainer\n};\n","\nconst getFileExtension = url => {\n let path = url.split(/[?#]/)[0];\n let segments = path.split('/');\n let filename = segments.pop();\n let ext = filename.split('.');\n if (ext.length > 0) {\n return '.' + ext.pop();\n }\n}\n\nexport default {\n getFileExtension\n}","import modelUtils from './utils/model';\nimport urlUtils from './utils/url';\n\n\nconst loaders = {};\n\n\nconst register = (ext, handler) => {\n loaders[ext] = {\n load: handler,\n objectCache: {}\n };\n};\n\n\nconst load = src => {\n let loader;\n let object;\n let ext = urlUtils.getFileExtension(src);\n\n if (ext) {\n loader = loaders[ext];\n }\n\n if (!loader) {\n console.error(`Couldn't load \"${src}\". Unknown object format \"${ext}\"`);\n return Promise.reject();\n }\n\n object = loader.objectCache[src];\n if (!object) {\n object = loader.load(src).then(obj => {\n // To help make sizing easier to deal with we normalize the models \n // dimenstions so its maximum width / height is 1. When rendering the\n // object we can scale it up by the width of the target DOM element.\n modelUtils.normalize(obj);\n\n // Finally the model is inserted into a container.\n return modelUtils.createContainer(obj);\n });\n loader.objectCache[src] = object;\n }\n \n return object.then(model => model.clone());\n};\n\n\nexport default {\n load,\n register\n};\n","/**\n * Strips the unit from a value (i.e. 100.55px) and converts the remaining\n * value to a number.\n */\nconst parseUnitValue = value => {\n return parseFloat(value || 0);\n};\n\n\n/**\n * Parses a CSS origin string (`perspective-origin`, `transform-origin`) into\n * it's X, Y and Z components and populates the supplied THREE.Vector3 with\n * the result.\n */\nconst parseOriginValue = (originString, vec3) => {\n let transformOrigin = originString.split(' ');\n vec3.set(\n parseUnitValue(transformOrigin[0]),\n parseUnitValue(transformOrigin[1]),\n parseUnitValue(transformOrigin[2])\n );\n};\n\n\n/**\n * Parses a CSS 3x2 matrix() or 4x4 matrix3d() string into its compontents and \n * populates the passed THREE.Matrix4 with the result.\n * \n * (https://keithclark.co.uk/articles/calculating-element-vertex-data-from-css-transforms/)\n */\n\nconst parseTransformValue = (matrixString, mat4) => {\n var c = matrixString.split(/\\s*[(),]\\s*/).slice(1, -1);\n\n if (c.length === 6) {\n // 'matrix()' (3x2)\n mat4.set(\n +c[0], -c[2], 0, +c[4],\n -c[1], +c[3], 0, -c[5],\n 0, 0, 1, 0,\n 0, 0, 0, 1\n );\n } else if (c.length === 16) {\n // matrix3d() (4x4)\n mat4.set(\n +c[0], -c[4], +c[8], +c[12],\n -c[1], +c[5], -c[9], -c[13],\n +c[2], -c[6], +c[10], +c[14],\n +c[3], +c[7], +c[11], +c[15]\n );\n } else {\n // handle 'none' or invalid values.\n mat4.identity();\n }\n};\n\n\nexport default {\n parseTransformValue,\n parseOriginValue,\n parseUnitValue\n};\n","import cssUtils from './css';\n\n/**\n * Resolves and returns the transform and perspective properties for a given\n * element.\n */\n\nconst getTransformForElement = elem => {\n let m1 = new THREE.Matrix4();\n let transformMatrix = new THREE.Matrix4();\n let transformOrigin = new THREE.Vector3();\n let transformOriginMatrix = new THREE.Matrix4();\n let osParent = elem;\n let stack = [];\n let posX = 0;\n let posY = 0;\n\n\n\n // We need to apply transforms from the root so we walk up the DOM tree,\n // pushing each node onto a stack. While we're walking to the DOM we also\n // resolve the elements X/Y position.\n while (elem) {\n if (elem === osParent) {\n posX += elem.offsetLeft;\n posY += elem.offsetTop;\n osParent = elem.offsetParent;\n }\n stack.push(elem);\n posX -= elem.scrollLeft;\n posY -= elem.scrollTop;\n elem = elem.parentElement;\n }\n\n\n m1.makeTranslation(posX, -posY, 0);\n\n // Now we can resolve transforms.\n while (elem = stack.pop()) {\n\n let style = getComputedStyle(elem);\n cssUtils.parseOriginValue(style.transformOrigin, transformOrigin);\n cssUtils.parseTransformValue(style.transform, transformMatrix);\n\n let ox = transformOrigin.x - elem.offsetWidth / 2;\n let oy = transformOrigin.y - elem.offsetHeight / 2;\n let oz = transformOrigin.z;\n\n // If the computed `transform-origin` is a value other than `50% 50% 0`\n // (`0,0,0` in THREE coordinate space) then we need to translate by the\n // origin before multiplying the element's transform matrix. Finally, we\n // need undo the translation.\n if (ox !== 0 || oy !== 0 || oz !== 0) {\n m1.multiply(transformOriginMatrix.makeTranslation(ox, -oy, oz));\n m1.multiply(transformMatrix);\n m1.multiply(transformOriginMatrix.makeTranslation(-ox, oy, -oz));\n } else {\n m1.multiply(transformMatrix);\n }\n }\n\n return m1;\n};\n\n\nconst getProjectionForElement = elem => {\n let perspectiveOrigin = new THREE.Vector3();\n let perspective;\n let clipBounds = {\n left: 0,\n top: 0,\n right: innerWidth,\n bottom: innerHeight\n };\n let cameraBounds = {\n left: 0,\n top: 0,\n right: innerWidth,\n bottom: innerHeight\n };\n\n\n while (elem) {\n let style = getComputedStyle(elem);\n let elemBounds = elem.getBoundingClientRect();\n\n // TODO: It's possible to nest perspectives. Need to research the impact\n // of this and, if possible, how to emulate it. For now, we'll just use\n // the last value found.\n let perspectiveValue = style.perspective;\n if (!perspective) {\n if (perspectiveValue !== 'none') {\n perspective = cssUtils.parseUnitValue(perspectiveValue);\n\n cameraBounds.top = elemBounds.top;\n cameraBounds.left = elemBounds.left;\n cameraBounds.right = elemBounds.right;\n cameraBounds.bottom = elemBounds.bottom;\n\n // TODO: strictly speaking, `perspective-origin` can be set on any\n // element, not just the one that has `perspective`. Research the impact\n // of setting perspective-origin on different elements in the DOM tree.\n let perspectiveOriginValue = style.perspectiveOrigin;\n if (perspectiveOriginValue) {\n cssUtils.parseOriginValue(perspectiveOriginValue, perspectiveOrigin);\n }\n }\n }\n\n\n if (style.overflow !== 'visible') {\n clipBounds.top = Math.max(elemBounds.top, clipBounds.top);\n clipBounds.left = Math.max(elemBounds.left, clipBounds.left);\n clipBounds.right = Math.min(elemBounds.right, clipBounds.right);\n clipBounds.bottom = Math.min(elemBounds.bottom, clipBounds.bottom);\n }\n\n elem = elem.parentElement;\n\n }\n\n return {\n perspective: perspective,\n perspectiveOrigin: perspectiveOrigin,\n clipBounds: clipBounds,\n cameraBounds: cameraBounds\n };\n};\n\n\n\nconst createStylesheet = cssText => {\n let styleElem = document.createElement('style');\n styleElem.textContent = cssText;\n return styleElem;\n};\n\n\n\nexport default {\n getTransformForElement,\n getProjectionForElement,\n createStylesheet\n};\n","import domUtils from './utils/dom';\n\nlet camera;\nlet overlayWidth;\nlet overlayHeight;\nlet perspectiveCamera;\nlet orthographicCamera;\nlet renderer;\nlet scene;\nlet light;\n\nconst objs = [];\n\n\nconst init = () => {\n if (scene) {\n return false;\n }\n\n // create the scene\n scene = new THREE.Scene();\n\n // add a light\n light = new THREE.PointLight(0x808080, 2, 0);\n light.position.set(0, 0, 0);\n scene.add(light);\n\n /*\n var sphereSize = .5;\n var pointLightHelper = new THREE.PointLightHelper( light, sphereSize, 0xff00ff );\n scene.add( pointLightHelper );\n */\n\n // create the WebGL renderer\n renderer = new THREE.WebGLRenderer({\n antialias: true,\n alpha: true\n });\n\n renderer.setScissorTest(true);\n renderer.setClearColor(0x000000, 0);\n renderer.autoClear = false;\n renderer.sortObjects = false;\n requestAnimationFrame(render);\n\n return renderer.domElement;\n};\n\n\nconst add = obj => {\n let index = objs.indexOf(obj);\n if (index === -1) {\n objs.push(obj);\n return true;\n }\n return false;\n};\n\n\nconst remove = (obj) => {\n let index = objs.indexOf(obj);\n if (index > -1) {\n objs.splice(index, 1);\n return true;\n }\n return false;\n};\n\n\nconst update = () => {\n overlayWidth = window.innerWidth;\n overlayHeight = window.innerHeight;\n camera = null;\n renderer.setSize(overlayWidth, overlayHeight);\n renderer.clear();\n\n // Walk over each object and update it\n objs.forEach(child => {\n let elem = child.elem;\n if (elem) {\n let projection;\n let transformMatrix;\n let clipHeight;\n let clipWidth;\n let model = child.children[0];\n let boundsElem = elem.shadowRoot.children[1];\n let size = model.userData.size;\n let elemWidth = elem.offsetWidth;\n let elemHeight = elem.offsetHeight;\n let scale = Math.min(elemWidth / size.x, elemHeight / size.y);\n let objWidth = size.x * scale;\n\n projection = domUtils.getProjectionForElement(elem);\n clipHeight = projection.clipBounds.bottom - projection.clipBounds.top;\n clipWidth = projection.clipBounds.right - projection.clipBounds.left;\n\n // If the elements clip area has a height or width of `0`, bail out early.\n if (clipWidth <= 0 || clipHeight <= 0) {\n return;\n }\n\n transformMatrix = domUtils.getTransformForElement(elem);\n\n // Apply the transform matrix of the DOM node to the model\n child.rotation.setFromRotationMatrix(transformMatrix);\n child.position.setFromMatrixPosition(transformMatrix);\n child.scale.setFromMatrixScale(transformMatrix);\n\n // Objects are normalised so we can scale them up by their width to\n // render them at the intended size.\n child.scale.multiplyScalar(scale);\n\n // Now scale the DOM bounding box so it matches the size and shape of the\n // model. An `IntersectionObserver` will use this DOM structure to decide\n // if this model needs to be rendered at the next animation frame.\n let scaleX = size.x * scale;\n let scaleY = size.y * scale;\n let scaleZ = size.z * scale;\n boundsElem.style.transform = `translate(-50%,-50%)scale3d(${scaleX},${scaleY},${scaleZ})`;\n\n // Three's coordinate space uses 0,0,0 as the screen centre so we need\n // to adjust the computed X/Y position back to the top-left of the screen\n // to match the CSS rendering position.\n child.position.x -= objWidth - elemWidth / 2;\n child.position.x += objWidth - overlayWidth / 2;\n child.position.y -= elemHeight / 2;\n child.position.y += overlayHeight / 2;\n\n // Determine which camera to use to project this model and set its\n // properties prior to rendering\n if (projection.perspective) {\n camera = setPerspectiveCamera(\n projection.cameraBounds,\n projection.perspective,\n projection.perspectiveOrigin\n );\n } else {\n camera = setOrthographicCamera(projection.cameraBounds);\n }\n\n light.position.x = projection.cameraBounds.left + (projection.cameraBounds.right - projection.cameraBounds.left) / 2 - overlayWidth / 2;\n light.position.y = overlayHeight / 2 - projection.cameraBounds.top - (projection.cameraBounds.bottom - projection.cameraBounds.top) / 2;\n light.position.z = camera.far;\n\n // Set the clipping box (scissor) and render the element.\n renderer.setScissor(\n projection.clipBounds.left,\n overlayHeight - projection.clipBounds.bottom,\n clipWidth,\n clipHeight\n );\n scene.add(child);\n renderer.render(scene, camera);\n scene.remove(child);\n\n }\n });\n\n return !!camera;\n};\n\n\nconst setOrthographicCamera = (bounds) => {\n let camera;\n\n if (!orthographicCamera) {\n orthographicCamera = new THREE.OrthographicCamera();\n }\n\n camera = orthographicCamera;\n camera.left = bounds.left - overlayWidth / 2;\n camera.top = -bounds.top + overlayHeight / 2;\n camera.bottom = -bounds.bottom + overlayHeight / 2;\n camera.right = bounds.right - overlayWidth / 2;\n camera.near = -700;\n camera.updateProjectionMatrix();\n\n return camera;\n};\n\n\nconst setPerspectiveCamera = (bounds, perspective, perspectiveOrigin) => {\n let camera;\n\n if (!perspectiveCamera) {\n perspectiveCamera = new THREE.PerspectiveCamera();\n }\n\n camera = perspectiveCamera;\n camera.fov = 180 * (2 * Math.atan(overlayHeight / 2 / perspective)) / Math.PI;\n camera.aspect = overlayWidth / overlayHeight;\n camera.position.set(0, 0, perspective);\n camera.updateProjectionMatrix();\n\n // Add perspective-origin\n let originX = overlayWidth / 2 - bounds.left - perspectiveOrigin.x;\n let originY = overlayHeight / 2 - bounds.top - perspectiveOrigin.y;\n\n\n // The default is origin for perspective is `50% 50%`, which equates to\n // `0,0`. If the author hasn't specified a different value we don't need\n // to make any adjustments to the projection matrix\n if (originX !== 0 || originY !== 0) {\n\n // copy the projection matrix\n let tmpMatrix = camera.projectionMatrix.clone();\n\n // set the camera projection matrix to the origin\n camera.projectionMatrix.makeTranslation(\n -originX / (overlayWidth / 2),\n originY / (overlayHeight / 2),\n 0\n );\n\n // apply to original camera projection matrix\n camera.projectionMatrix.multiply(tmpMatrix);\n\n // remove the origin offset\n tmpMatrix.makeTranslation(originX, -originY, 0);\n camera.projectionMatrix.multiply(tmpMatrix);\n\n }\n\n return camera;\n};\n\n\nconst render = () => {\n requestAnimationFrame(render);\n update();\n};\n\n\nexport default {\n init,\n add,\n remove,\n render\n};\n","import modelLoader from './modelLoader';\nimport modelLayer from './modelLayer';\nimport domUtils from './utils/dom';\n\n\nconst objects = new WeakMap();\n\n\nconst ATTR_TO_CUSTOM_PROP_MAP = {\n 'width': '--xModelWidth',\n 'height': '--xModelHeight'\n}\n\nconst CANVAS_DEFAULT_STYLES =\n ':root{' +\n 'transform-style:flat!important;' +\n '}' +\n '#x-model-renderLayer{' +\n 'position:fixed;' +\n 'top:0;' +\n 'left:0;' +\n 'pointer-events:none' +\n '}';\n\n\nconst ELEMENT_DEFAULT_STYLES =\n ':host{' +\n 'display:inline-block;' +\n 'width:var(--xModelWidth,200px);' +\n 'height:var(--xModelHeight,150px);' +\n 'transform-style:var(--xModelBoundingBoxTransformStyle, preserve-3d)' +\n '}' +\n '.boundingBox{' +\n 'visibility:var(--xModelBoundingBoxVisibility, hidden);' +\n 'transform-style:inherit;' +\n 'position:relative;' +\n 'left:50%;' +\n 'top:50%;' +\n 'width:1px;' +\n 'height:1px;' +\n 'background:#08c' +\n '}' +\n '.boundingBox__face{' +\n 'position:absolute;' +\n 'width:1px;' +\n 'height:1px;' +\n 'background:#0c0' +\n '}' +\n '.boundingBox__face:nth-child(1){transform:translateZ(-.5px)}' +\n '.boundingBox__face:nth-child(2){transform:translateZ(.5px)}' +\n '.boundingBox__face:nth-child(3){transform:translateY(-.5px)rotateX(90deg)}' +\n '.boundingBox__face:nth-child(4){transform:translateY(.5px)rotateX(-90deg)}' +\n '.boundingBox__face:nth-child(5){transform:translateX(.5px)rotateY(-90deg)}' +\n '.boundingBox__face:nth-child(6){transform:translateX(-.5px)rotateY(-90deg)}';\n\n\nconst ELEMENT_HTML =\n `` +\n '
' +\n '
'.repeat(6) +\n '
';\n\n\nlet styleElem;\nlet intersectionObserver;\n\n\nconst intersectionCallback = entries => {\n entries.forEach(entry => {\n let obj = objects.get(entry.target.parentElement);\n if (entry.isIntersecting) {\n if (obj.axisInView < 6) {\n if (obj.axisInView === 0) {\n modelLayer.add(obj);\n }\n obj.axisInView++;\n }\n } else {\n if (obj.axisInView > 0) {\n obj.axisInView--;\n if (obj.axisInView === 0) {\n modelLayer.remove(obj);\n }\n }\n }\n });\n};\n\n\nconst initModelLayer = () => {\n // The first time an element is added to the document we inject a\n // stylesheet that contains its default styles. Ideally this would be\n // appended to the shadow DOM, but support for that isn't great right now.\n styleElem = domUtils.createStylesheet(CANVAS_DEFAULT_STYLES);\n let head = document.documentElement.firstChild;\n head.insertBefore(styleElem, head.firstChild);\n\n // Initialize the model layer and append the resulting DOM node to the\n // document root - outside the to prevent perspective or transform\n // styles from affecting it.\n let renderDomElement = modelLayer.init();\n renderDomElement.setAttribute('id', 'x-model-renderLayer');\n document.documentElement.appendChild(renderDomElement);\n\n // Use an intersection observer to watch for elements entering and leaving\n // the viewport\n intersectionObserver = new IntersectionObserver(intersectionCallback);\n\n};\n\n\nexport default class extends HTMLElement {\n\n constructor() {\n super();\n // Create six child elements. These will be rotated and translated along the\n // X Y and Z axis to create a bounding box around the model. These\n // elements will be monitored by an `IntersectionObserver` which will add\n // the model to the scene if the any elements are visible in the viewport\n // and remove the model when no elements are visible\n this.attachShadow({mode: 'open'});\n this.shadowRoot.innerHTML = ELEMENT_HTML;\n }\n\n static get observedAttributes() {\n return ['src', 'width', 'height'];\n }\n\n connectedCallback() {\n if (!styleElem) {\n initModelLayer();\n }\n let obj = objects.get(this);\n if (obj && obj.elem !== this) {\n let model = obj.children[0];\n let size = model.userData.size;\n let scale = Math.min(this.offsetWidth / size.x, this.offsetHeight / size.y);\n let scaleX = size.x * scale;\n let scaleY = size.y * scale;\n let scaleZ = size.z * scale;\n\n // Scale and distort the DOM bounding box (a cube) along X, Y and Z axis\n // so it matches the size and shape of the models bounding box.\n let box = this.shadowRoot.querySelector('.boundingBox');\n box.style.transform = `translate(-50%,-50%)scale3d(${scaleX},${scaleY},${scaleZ})`;\n\n // Monitor each face with an `IntersectionObserver` so we can determine if\n // the model is visible in the viewport when it's rendered with\n // perspective projection.\n let faces = Array.from(box.children);\n faces.forEach(elem => intersectionObserver.observe(elem));\n\n obj.elem = this;\n obj.axisInView = 0;\n\n objects.set(box, obj);\n }\n }\n\n disconnectedCallback() {\n let obj = objects.get(this);\n if (obj && obj.elem === this) {\n let box = this.shadowRoot.querySelector('.boundingBox');\n let faces = Array.from(box.children);\n faces.forEach(elem => intersectionObserver.unobserve(elem));\n obj.elem = null;\n }\n }\n\n attributeChangedCallback(attribute, oldValue, newValue) {\n if (attribute === 'width' || attribute === 'height') {\n if (newValue !== null) {\n newValue += 'px';\n }\n let customProp = ATTR_TO_CUSTOM_PROP_MAP[attribute];\n this.shadowRoot.children[0].sheet.rules[0].style.setProperty(customProp, newValue);\n } else if (attribute === 'src') {\n // call the disconnected callback handler to release the current model if\n // one is attached\n this.disconnectedCallback();\n\n modelLoader.load(newValue).then(obj => {\n let event = new UIEvent('load');\n this.dispatchEvent(event);\n objects.set(this, obj);\n this.connectedCallback();\n }).catch(e => {\n let event = new UIEvent('error');\n this.dispatchEvent(event);\n });\n }\n }\n\n}\n","let loader;\n\n\nexport default src => {\n\n return new Promise((resolve, reject) => {\n\n const loadHandler = gltf => {\n resolve(gltf.scene);\n }\n\n const errorHandler = () => {\n reject();\n }\n\n if (!loader) {\n loader = new THREE.GLTFLoader();\n }\n\n return loader.load(src, loadHandler, null, errorHandler);\n\n });\n}\n","let loader;\n\n\nexport default src => {\n\n return new Promise((resolve, reject) => {\n\n const loadHandler = obj => {\n resolve(obj);\n }\n\n const errorHandler = () => {\n reject();\n }\n\n if (!loader) {\n loader = new THREE.OBJLoader();\n }\n\n return loader.load(src, loadHandler, null, errorHandler);\n\n });\n}\n","import HTMLModelElement from './modelElement.js';\nimport modelLoader from './modelLoader.js';\nimport gltfLoader from './loaders/gltf';\nimport objLoader from './loaders/obj';\n\n\nif ('customElements' in window) {\n\n if (!('THREE' in window)) {\n throw 'THREE (threejs.org) is required.';\n }\n\n if ('GLTFLoader' in THREE) {\n modelLoader.register('.gltf', gltfLoader);\n modelLoader.register('.glb', gltfLoader);\n }\n\n if ('OBJLoader' in THREE) {\n modelLoader.register('.obj', objLoader);\n }\n\n customElements.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E;EAC5B,IAAI,MAAM,kCAAkC,CAAC;EAC7C,GAAG;;EAEH,EAAE,IAAI,YAAY,IAAI,KAAK,EAAE;EAC7B,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;EAC9C,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;EAC7C,GAAG;;EAEH,EAAE,IAAI,WAAW,IAAI,KAAK,EAAE;EAC5B,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;EAC5C,GAAG;;EAEH,EAAE,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;EACrD,CAAC;;;;"} \ No newline at end of file diff --git a/dist/model-element.min.js b/dist/model-element.min.js index 664b8e4..5d627d1 100644 --- a/dist/model-element.min.js +++ b/dist/model-element.min.js @@ -1,2 +1,2 @@ -// 3D Model Element | (C) Keith Clark | MIT | https://github.com/keithclark/3d-model-element -(function(){'use strict';var a=Math.max,b={normalize:(b)=>{let c=new THREE.Box3().setFromObject(b),d=new THREE.Vector3;c.getCenter(b.position),c.getSize(d);let e=1/a(d.x,d.y);return b.position.multiplyScalar(-e),b.scale.set(e,e,e),b},createDebugBoundingBox:()=>{let a=new THREE.LineBasicMaterial({color:65280}),b=new THREE.PlaneGeometry(1,1),c=new THREE.WireframeGeometry(b),d=new THREE.LineSegments(c,a);return d},createContainer:(a)=>{let b=new THREE.Object3D;return!1,b.add(a),b}},c={getFileExtension:(a)=>{let b=a.split(/[?#]/)[0],c=b.split('/'),d=c.pop(),e=d.split('.');if(0{let e,f,g=c.getFileExtension(a);return(g&&(e=d[g]),!e)?(console.error(`Couldn't load "${a}". Unknown object format "${g}"`),Promise.reject()):(f=e.objectCache[a],f||(f=e.load(a).then((a)=>(b.normalize(a),b.createContainer(a))),e.objectCache[a]=f),f.then((a)=>a.clone()))};var f={load:e,register:(a,b)=>{d[a]={load:b,objectCache:{}}}};const g=(a)=>parseFloat(a||0);var h={parseTransformValue:(a,b)=>{var d=a.split(/\s*[(),]\s*/).slice(1,-1);6===d.length?b.set(+d[0],-d[2],0,+d[4],-d[1],+d[3],0,-d[5],0,0,1,0,0,0,0,1):16===d.length?b.set(+d[0],-d[4],+d[8],+d[12],-d[1],+d[5],-d[9],-d[13],+d[2],-d[6],+d[10],+d[14],+d[3],+d[7],+d[11],+d[15]):b.identity()},parseOriginValue:(a,b)=>{let c=a.split(' ');b.set(g(c[0]),g(c[1]),g(c[2]))},parseUnitValue:g};const i=(a)=>{let b=document.createElement('style');return b.textContent=a,b};var j={getTransformForElement:(a)=>{let b=new THREE.Matrix4,c=new THREE.Matrix4,d=new THREE.Vector3,e=new THREE.Matrix4,f=a,g=[],i=0,j=0;if(0===a.offsetWidth||0===a.offsetHeight)return b;for(i-=a.offsetWidth/2,j+=a.offsetHeight/2;a;)a===f&&(i+=a.offsetLeft,j+=a.offsetTop,f=a.offsetParent),g.push(a),i-=a.scrollLeft,j-=a.scrollTop,a=a.parentElement;for(b.makeTranslation(i,-j,0);a=g.pop();){let f=getComputedStyle(a);h.parseOriginValue(f.transformOrigin,d),h.parseTransformValue(f.transform,c);let g=d.x-a.offsetWidth/2,i=d.y-a.offsetHeight/2,j=d.z;0!=g||0!=i||0!==j?(b.multiply(e.makeTranslation(g,-i,j)),b.multiply(c),b.multiply(e.makeTranslation(-g,i,-j))):b.multiply(c)}return b},getProjectionForElement:(b)=>{var c=Math.min;let d,e=new THREE.Vector3,f={left:0,top:0,right:innerWidth,bottom:innerHeight},g={left:0,top:0,right:innerWidth,bottom:innerHeight};for(;b;){let i=getComputedStyle(b),j=b.getBoundingClientRect(),k=i.perspective;if(!d&&'none'!==k){d=h.parseUnitValue(k),g.top=j.top,g.left=j.left,g.right=j.right,g.bottom=j.bottom;let a=i.perspectiveOrigin;a&&h.parseOriginValue(a,e)}'visible'!==i.overflow&&(f.top=a(j.top,f.top),f.left=a(j.left,f.left),f.right=c(j.right,f.right),f.bottom=c(j.bottom,f.bottom)),b=b.parentElement}return{perspective:d,perspectiveOrigin:e,clipBounds:f,cameraBounds:g}},createStylesheet:i};let k,l,m,n,o,p,q,r;const s=[],t=()=>!q&&(q=new THREE.Scene,r=new THREE.PointLight(8421504,2,0),r.position.set(0,0,0),q.add(r),p=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),p.setScissorTest(!0),p.setClearColor(0,0),p.autoClear=!1,p.sortObjects=!1,requestAnimationFrame(x),p.domElement),u=()=>(l=window.innerWidth,m=window.innerHeight,k=null,p.setSize(l,m),p.clear(),s.forEach((a)=>{let b=a.elem;if(b){let c,d,e,f,g=b.offsetWidth;if(0===g)return;if(c=j.getProjectionForElement(b),e=c.clipBounds.bottom-c.clipBounds.top,f=c.clipBounds.right-c.clipBounds.left,0>=f||0>=e)return;d=j.getTransformForElement(b),a.rotation.setFromRotationMatrix(d),a.position.setFromMatrixPosition(d),a.scale.setFromMatrixScale(d),a.scale.multiplyScalar(g),a.position.x+=g-l/2,a.position.y+=m/2,k=c.perspective?w(c.cameraBounds,c.perspective,c.perspectiveOrigin):v(c.cameraBounds),r.position.x=c.cameraBounds.left+(c.cameraBounds.right-c.cameraBounds.left)/2-l/2,r.position.y=m/2-c.cameraBounds.top-(c.cameraBounds.bottom-c.cameraBounds.top)/2,r.position.z=k.far,p.setScissor(c.clipBounds.left,c.clipBounds.top,f,e),q.add(a),p.render(q,k),q.remove(a)}}),!!k),v=(a)=>{let b;return o||(o=new THREE.OrthographicCamera),b=o,b.left=a.left-l/2,b.top=-a.top+m/2,b.bottom=-a.bottom+m/2,b.right=a.right-l/2,b.near=-700,b.updateProjectionMatrix(),b},w=(a,b,c)=>{let d;n||(n=new THREE.PerspectiveCamera),d=n,d.fov=180*(2*Math.atan(m/2/b))/Math.PI,d.aspect=l/m,d.position.set(0,0,b),d.updateProjectionMatrix();let e=l/2-a.left-c.x,f=m/2-a.top-c.y;if(0!=e||0!=f){let a=d.projectionMatrix.clone();d.projectionMatrix.makeTranslation(-e/(l/2),f/(m/2),0),d.projectionMatrix.multiply(a),a.makeTranslation(e,-f,0),d.projectionMatrix.multiply(a)}return d},x=()=>{requestAnimationFrame(x),u()};var y={init:t,add:(a)=>{let b=s.indexOf(a);return!(-1!==b)&&(s.push(a),!0)},remove:(a)=>{let b=s.indexOf(a);return!!(-1{A=j.createStylesheet('#x-model-renderLayer{position:fixed;top:0;left:0;pointer-events:none}x-model{display:inline-block;width:250px;height:250px}');let a=document.documentElement.firstChild;a.insertBefore(A,a.firstChild);let b=y.init();b.setAttribute('id','x-model-renderLayer'),document.documentElement.appendChild(b)};class C extends HTMLElement{constructor(){super()}static get observedAttributes(){return['src']}connectedCallback(){A||B();let a=z.get(this);a&&a.elem!==this&&(a.elem=this,y.add(a))}disconnectedCallback(){let a=z.get(this);a&&a.elem===this&&(y.remove(a),a.elem=null)}attributeChangedCallback(a,b,c){'src'===a&&(this.disconnectedCallback(),f.load(c).then((a)=>{let b=new UIEvent('load');this.dispatchEvent(b),z.set(this,a),this.connectedCallback()}).catch(()=>{let a=new UIEvent('error');this.dispatchEvent(a)}))}}let D;var E=(a)=>new Promise((b,c)=>{return D||(D=new THREE.GLTFLoader),D.load(a,(a)=>{b(a.scene)},null,()=>{c()})});let F;var G=(a)=>new Promise((b,c)=>{return F||(F=new THREE.OBJLoader),F.load(a,(a)=>{b(a)},null,()=>{c()})});if('customElements'in window){if(!('THREE'in window))throw'THREE (threejs.org) is required.';'GLTFLoader'in THREE&&(f.register('.gltf',E),f.register('.glb',E)),'OBJLoader'in THREE&&f.register('.obj',G),customElements.define('x-model',C)}})(); \ No newline at end of file +//! 3D Model Element v1.0.2 | (C) Keith Clark | MIT | https://github.com/keithclark/3d-model-element +(function(){'use strict';var a=Math.min,b=Math.max,c={normalize:a=>{let c=new THREE.Box3().setFromObject(a),d=new THREE.Vector3;c.getCenter(a.position),c.getSize(d);let e=1/b(d.x,d.y);return a.position.multiplyScalar(-e),a.scale.multiplyScalar(e),a.userData.size=d.multiplyScalar(e).clone(),a},createContainer:a=>{let b=new THREE.Object3D;return b.add(a),b}},d={getFileExtension:a=>{let b=a.split(/[?#]/)[0],c=b.split("/"),d=c.pop(),e=d.split(".");if(0{let b,f,g=d.getFileExtension(a);return(g&&(b=e[g]),!b)?(console.error(`Couldn't load "${a}". Unknown object format "${g}"`),Promise.reject()):(f=b.objectCache[a],f||(f=b.load(a).then(a=>(c.normalize(a),c.createContainer(a))),b.objectCache[a]=f),f.then(a=>a.clone()))};var g={load:f,register:(a,b)=>{e[a]={load:b,objectCache:{}}}};const h=a=>parseFloat(a||0);var i={parseTransformValue:(a,b)=>{var d=a.split(/\s*[(),]\s*/).slice(1,-1);6===d.length?b.set(+d[0],-d[2],0,+d[4],-d[1],+d[3],0,-d[5],0,0,1,0,0,0,0,1):16===d.length?b.set(+d[0],-d[4],+d[8],+d[12],-d[1],+d[5],-d[9],-d[13],+d[2],-d[6],+d[10],+d[14],+d[3],+d[7],+d[11],+d[15]):b.identity()},parseOriginValue:(a,b)=>{let c=a.split(" ");b.set(h(c[0]),h(c[1]),h(c[2]))},parseUnitValue:h};const j=a=>{let b=document.createElement("style");return b.textContent=a,b};var k={getTransformForElement:a=>{let b=new THREE.Matrix4,c=new THREE.Matrix4,d=new THREE.Vector3,e=new THREE.Matrix4,f=a,g=[],h=0,j=0;for(;a;)a===f&&(h+=a.offsetLeft,j+=a.offsetTop,f=a.offsetParent),g.push(a),h-=a.scrollLeft,j-=a.scrollTop,a=a.parentElement;for(b.makeTranslation(h,-j,0);a=g.pop();){let f=getComputedStyle(a);i.parseOriginValue(f.transformOrigin,d),i.parseTransformValue(f.transform,c);let g=d.x-a.offsetWidth/2,h=d.y-a.offsetHeight/2,j=d.z;0!=g||0!==h||0!==j?(b.multiply(e.makeTranslation(g,-h,j)),b.multiply(c),b.multiply(e.makeTranslation(-g,h,-j))):b.multiply(c)}return b},getProjectionForElement:c=>{let d,e=new THREE.Vector3,f={left:0,top:0,right:innerWidth,bottom:innerHeight},g={left:0,top:0,right:innerWidth,bottom:innerHeight};for(;c;){let h=getComputedStyle(c),j=c.getBoundingClientRect(),k=h.perspective;if(!d&&"none"!==k){d=i.parseUnitValue(k),g.top=j.top,g.left=j.left,g.right=j.right,g.bottom=j.bottom;let a=h.perspectiveOrigin;a&&i.parseOriginValue(a,e)}"visible"!==h.overflow&&(f.top=b(j.top,f.top),f.left=b(j.left,f.left),f.right=a(j.right,f.right),f.bottom=a(j.bottom,f.bottom)),c=c.parentElement}return{perspective:d,perspectiveOrigin:e,clipBounds:f,cameraBounds:g}},createStylesheet:j};let l,m,n,o,p,q,r,s;const t=[],u=()=>!r&&(r=new THREE.Scene,s=new THREE.PointLight(8421504,2,0),s.position.set(0,0,0),r.add(s),q=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),q.setScissorTest(!0),q.setClearColor(0,0),q.autoClear=!1,q.sortObjects=!1,requestAnimationFrame(y),q.domElement),v=()=>(m=window.innerWidth,n=window.innerHeight,l=null,q.setSize(m,n),q.clear(),t.forEach(b=>{let c=b.elem;if(c){let d,e,f,g,h=b.children[0],i=c.shadowRoot.children[1],j=h.userData.size,o=c.offsetWidth,p=c.offsetHeight,t=a(o/j.x,p/j.y),u=j.x*t;if(d=k.getProjectionForElement(c),f=d.clipBounds.bottom-d.clipBounds.top,g=d.clipBounds.right-d.clipBounds.left,0>=g||0>=f)return;e=k.getTransformForElement(c),b.rotation.setFromRotationMatrix(e),b.position.setFromMatrixPosition(e),b.scale.setFromMatrixScale(e),b.scale.multiplyScalar(t);let v=j.x*t,y=j.y*t,z=j.z*t;i.style.transform=`translate(-50%,-50%)scale3d(${v},${y},${z})`,b.position.x-=u-o/2,b.position.x+=u-m/2,b.position.y-=p/2,b.position.y+=n/2,l=d.perspective?x(d.cameraBounds,d.perspective,d.perspectiveOrigin):w(d.cameraBounds),s.position.x=d.cameraBounds.left+(d.cameraBounds.right-d.cameraBounds.left)/2-m/2,s.position.y=n/2-d.cameraBounds.top-(d.cameraBounds.bottom-d.cameraBounds.top)/2,s.position.z=l.far,q.setScissor(d.clipBounds.left,n-d.clipBounds.bottom,g,f),r.add(b),q.render(r,l),r.remove(b)}}),!!l),w=a=>{let b;return p||(p=new THREE.OrthographicCamera),b=p,b.left=a.left-m/2,b.top=-a.top+n/2,b.bottom=-a.bottom+n/2,b.right=a.right-m/2,b.near=-700,b.updateProjectionMatrix(),b},x=(a,b,c)=>{let d;o||(o=new THREE.PerspectiveCamera),d=o,d.fov=180*(2*Math.atan(n/2/b))/Math.PI,d.aspect=m/n,d.position.set(0,0,b),d.updateProjectionMatrix();let e=m/2-a.left-c.x,f=n/2-a.top-c.y;if(0!=e||0!==f){let a=d.projectionMatrix.clone();d.projectionMatrix.makeTranslation(-e/(m/2),f/(n/2),0),d.projectionMatrix.multiply(a),a.makeTranslation(e,-f,0),d.projectionMatrix.multiply(a)}return d},y=()=>{requestAnimationFrame(y),v()};var z={init:u,add:a=>{let b=t.indexOf(a);return!(-1!==b)&&(t.push(a),!0)},remove:a=>{let b=t.indexOf(a);return!!(-1${":host{display:inline-block;width:var(--xModelWidth,200px);height:var(--xModelHeight,150px);transform-style:var(--xModelBoundingBoxTransformStyle, preserve-3d)}.boundingBox{visibility:var(--xModelBoundingBoxVisibility, hidden);transform-style:inherit;position:relative;left:50%;top:50%;width:1px;height:1px;background:#08c}.boundingBox__face{position:absolute;width:1px;height:1px;background:#0c0}.boundingBox__face:nth-child(1){transform:translateZ(-.5px)}.boundingBox__face:nth-child(2){transform:translateZ(.5px)}.boundingBox__face:nth-child(3){transform:translateY(-.5px)rotateX(90deg)}.boundingBox__face:nth-child(4){transform:translateY(.5px)rotateX(-90deg)}.boundingBox__face:nth-child(5){transform:translateX(.5px)rotateY(-90deg)}.boundingBox__face:nth-child(6){transform:translateX(-.5px)rotateY(-90deg)}"}`+"
"+"
".repeat(6)+"
";let D,E;const F=a=>{a.forEach(a=>{let b=A.get(a.target.parentElement);a.isIntersecting?6>b.axisInView&&(0===b.axisInView&&z.add(b),b.axisInView++):0{D=k.createStylesheet(":root{transform-style:flat!important;}#x-model-renderLayer{position:fixed;top:0;left:0;pointer-events:none}");let a=document.documentElement.firstChild;a.insertBefore(D,a.firstChild);let b=z.init();b.setAttribute("id","x-model-renderLayer"),document.documentElement.appendChild(b),E=new IntersectionObserver(F)};class H extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=C}static get observedAttributes(){return["src","width","height"]}connectedCallback(){D||G();let b=A.get(this);if(b&&b.elem!==this){let c=b.children[0],d=c.userData.size,e=a(this.offsetWidth/d.x,this.offsetHeight/d.y),f=d.x*e,g=d.y*e,h=d.z*e,i=this.shadowRoot.querySelector(".boundingBox");i.style.transform=`translate(-50%,-50%)scale3d(${f},${g},${h})`;let j=Array.from(i.children);j.forEach(a=>E.observe(a)),b.elem=this,b.axisInView=0,A.set(i,b)}}disconnectedCallback(){let a=A.get(this);if(a&&a.elem===this){let b=this.shadowRoot.querySelector(".boundingBox"),c=Array.from(b.children);c.forEach(a=>E.unobserve(a)),a.elem=null}}attributeChangedCallback(a,b,c){if("width"===a||"height"===a){null!==c&&(c+="px");let b=B[a];this.shadowRoot.children[0].sheet.rules[0].style.setProperty(b,c)}else"src"===a&&(this.disconnectedCallback(),g.load(c).then(a=>{let b=new UIEvent("load");this.dispatchEvent(b),A.set(this,a),this.connectedCallback()}).catch(()=>{let a=new UIEvent("error");this.dispatchEvent(a)}))}}let I;var J=a=>new Promise((b,c)=>{return I||(I=new THREE.GLTFLoader),I.load(a,a=>{b(a.scene)},null,()=>{c()})});let K;var L=a=>new Promise((b,c)=>{return K||(K=new THREE.OBJLoader),K.load(a,a=>{b(a)},null,()=>{c()})});if("customElements"in window){if(!("THREE"in window))throw"THREE (threejs.org) is required.";"GLTFLoader"in THREE&&(g.register(".gltf",J),g.register(".glb",J)),"OBJLoader"in THREE&&g.register(".obj",L),customElements.define("x-model",H)}})(); \ No newline at end of file