isometric-css
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -38,2 +38,3 @@ import { VIEW, AXIS } from '../constants'; | ||
texture?: Texture; | ||
parentRotations: Rotation[]; | ||
} | ||
@@ -40,0 +41,0 @@ export interface ElementData { |
# Changelog | ||
## [2.1.0] - 2021-03-19 | ||
- Implemented the rotation of groups containing planes | ||
## [2.0.0] - 2021-02-10 | ||
@@ -4,0 +8,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){for(var r in e)t[r]=e[r];e.__esModule&&Object.defineProperty(t,"__esModule",{value:!0})}(exports,(()=>{"use strict";var t={506:(t,e,r)=>{r.r(e),r.d(e,{default:()=>i});const i=function(t){for(var e,r=0,i=0,o=t.length;o>=4;++i,o-=4)e=1540483477*(65535&(e=255&t.charCodeAt(i)|(255&t.charCodeAt(++i))<<8|(255&t.charCodeAt(++i))<<16|(255&t.charCodeAt(++i))<<24))+(59797*(e>>>16)<<16),r=1540483477*(65535&(e^=e>>>24))+(59797*(e>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(o){case 3:r^=(255&t.charCodeAt(i+2))<<16;case 2:r^=(255&t.charCodeAt(i+1))<<8;case 1:r=1540483477*(65535&(r^=255&t.charCodeAt(i)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)}},158:function(t,e,r){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var o=r(37),n=r(539),s=r(995),a=function(){function t(){this._elements=new Map,this._classes=new Map,this._styles=new s.Styles}return t.prototype.removeClasses=function(t,e){t.classList.remove(e);var r=this._classes.get(e),i=r.findIndex((function(e){return e===t}));r.splice(i,1),0===r.length&&(this._classes.delete(e),this._styles.remove(e))},t.prototype.process=function(t,e){var r=this._elements.get(t),i=this._styles.getRuleData(e);if(r){if(r.selector===i.selector)return;this.removeClasses(t,r.selector)}t.classList.add(i.selector);var o=this._classes.get(i.selector);o?o.push(t):(this._styles.insert(i.selector,i.declaration),this._classes.set(i.selector,[t])),this._elements.set(t,{plane:e,selector:i.selector,rule:i.rule})},t.prototype.addElement=function(t){var e=n.getPlaneFromElement(t);this.process(t,e)},t.prototype.removeElement=function(t){n.resetElementIsometricData(t);var e=this._elements.get(t);e&&(this._elements.delete(t),this.removeClasses(t,e.selector))},t.prototype.setElementView=function(t,e){if(e===o.VIEW.top||e===o.VIEW.front||e===o.VIEW.side){var r=this._elements.get(t);this.process(t,r?i(i({},r.plane),{view:e}):{view:e})}},t.prototype.setElementPosition=function(t,e){if(+e.right||+e.left||+e.top){var r=this._elements.get(t);this.process(t,r?i(i({},r.plane),{position:i(i({},r.plane.position),e)}):{position:e})}},t.prototype.setElementRotation=function(t,e){if((e.axis===o.AXIS.right||e.axis===o.AXIS.left||e.axis===o.AXIS.top)&&+e.value){var r=this._elements.get(t);this.process(t,r?i(i({},r.plane),{rotation:e}):{rotation:e})}},t.prototype.setElementTexture=function(t,e){if(!("string"!=typeof e.url||e.size&&"string"!=typeof e.size||e.pixelated&&"boolean"!=typeof e.pixelated)){var r=this._elements.get(t);this.process(t,r?i(i({},r.plane),{texture:i(i({},r.plane.texture),e)}):{texture:e})}},t}();e.default=new a},995:function(t,e,r){var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var o=r(506),n=r(37),s=r(821),a=r(854),l=r(361),u=function(){function t(){this._style=null,this.scale=a.round(n.SCALE),this.P50="50%",this.transformBefore="translate(-"+this.P50+", -"+this.P50+")",this.tranformAfterTop="translate(-"+this.P50+", "+this.P50+")",this.transformAfterFront="translate(-"+this.P50+", -"+this.P50+")",this.transformAfterSide="translate("+this.P50+", -"+this.P50+")",this.baseDeclarations={position:"absolute"},this.transformOriginDeclarations={transformOrigin:this.P50+" "+this.P50,MsTransformOrigin:this.P50+" "+this.P50,WebkitTransformOrigin:this.P50+" "+this.P50}}return Object.defineProperty(t.prototype,"sheet",{get:function(){return this._style?this._style.sheet:null},enumerable:!1,configurable:!0}),t.prototype.getTransform=function(t,e){var r=l.getViewMatrix(t,e);if(!r)return null;var i="matrix("+a.round(r[0][0])+","+a.round(r[1][0])+","+a.round(r[0][1])+","+a.round(r[1][1])+",0,0)",o=this.transformBefore+" "+i+" scale("+this.scale+")";switch(t){case n.VIEW.top:return o+" "+this.tranformAfterTop;case n.VIEW.front:return o+" "+this.transformAfterFront;case n.VIEW.side:return o+" "+this.transformAfterSide}},t.prototype.declarationString=function(t){var e=this;return Object.entries(t).reduce((function(t,r){return Array.isArray(r[1])?t+"\n "+r[1].map((function(t){return e.declarationString(t)})).join("\n"):t+"\n "+s.kebab(r[0])+": "+r[1]+";"}),"")},t.prototype.tranformPlaneToRule=function(t){var e=this.getTransform(t.view,t.rotation),r=e?i(i(i({},this.baseDeclarations),this.transformOriginDeclarations),{transform:e,MsTransform:e,WebkitTransform:e}):i({},this.baseDeclarations);if(t.position){var o=a.isometricToPoint(t.position);r.left=o.x+"px",r.top=o.y+"px"}return t.texture&&(r.backgroundImage='url("'+t.texture.url+'")',r.backgroundSize=t.texture.size||"cover",t.texture.pixelated&&(r.MsInterpolationMode="nearest-neighbor",r.imageRendering="pixelated",r.fallbacks=[{imageRendering:"crisp-edges"}])),r},t.prototype.init=function(){this._style=document.createElement("style"),this._style.dataset.isometric="",document.getElementsByTagName("head")[0].appendChild(this._style)},t.prototype.getRule=function(t){return this.tranformPlaneToRule(t)},t.prototype.getDeclarationString=function(t){return this.declarationString(t)},t.prototype.getSelector=function(t){return n.NAMESPACE+"-"+o.default(t)},t.prototype.getRuleData=function(t){var e=this.getRule(t),r=this.getDeclarationString(e);return{rule:e,declaration:r,selector:this.getSelector(r)}},t.prototype.insert=function(t,e){this.sheet||this.init(),this.sheet.insertRule("."+t+" {\n"+e+"\n}")},t.prototype.remove=function(t){var e=this;Array.prototype.some.call(this.sheet.cssRules,(function(r,i){return!(!r||r.selectorText.slice(1)!==t||(e.sheet.deleteRule(i),0))}))},t}();e.Styles=u},37:(t,e)=>{var r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.TYPE_UNDEFINED=e.AXIS=e.VIEW=e.ROT_CMA=e.ROT_45=e.ROT_60=e.SCALE=e.HSQRT3=e.DECIMALS=e.NAMESPACE=void 0,e.NAMESPACE="isometric",e.DECIMALS=6,e.HSQRT3=+(Math.sqrt(3)/2).toFixed(e.DECIMALS),e.SCALE=Math.sqrt(1.5),e.ROT_60=Math.PI/3,e.ROT_45=Math.PI/4,e.ROT_CMA=Math.atan(Math.SQRT2),(i=e.VIEW||(e.VIEW={})).top="top",i.front="front",i.side="side",(r=e.AXIS||(e.AXIS={})).right="right",r.left="left",r.top="top",e.TYPE_UNDEFINED="undefined"},607:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IsometricCSS=void 0;var i=r(37),o=r(158);e.IsometricCSS={processDOM:function(){Array.prototype.forEach.call(document.querySelectorAll("."+i.NAMESPACE),(function(t){o.default.addElement(t)}))},processElement:function(t){o.default.addElement(t)},resetElement:function(t){o.default.removeElement(t)},setView:function(t,e){o.default.setElementView(t,e)},setRotation:function(t,e){o.default.setElementRotation(t,e)},setPosition:function(t,e){o.default.setElementPosition(t,e)},setTexture:function(t,e){o.default.setElementTexture(t,e)}},typeof window!==i.TYPE_UNDEFINED&&typeof document!==i.TYPE_UNDEFINED&&(window.IsometricCSS=e.IsometricCSS,window.addEventListener("DOMContentLoaded",(function(){e.IsometricCSS.processDOM()})))},539:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resetElementIsometricData=e.getPlaneFromElement=void 0;var i=r(37);e.getPlaneFromElement=function(t){var e=t.dataset.view?t.dataset.view:null,r=+(t.dataset.right||0),i=+(t.dataset.left||0),o=+(t.dataset.top||0),n=t.dataset.rotationAxis?t.dataset.rotationAxis:null,s=+(t.dataset.rotationValue||0),a=t.dataset.texture,l=t.dataset.textureSize||"cover",u="true"===t.dataset.texturePixelated,c={};return e&&(c.view=e),(r||i||o)&&(c.position={right:r,left:i,top:o}),n&&s&&(c.rotation={axis:n,value:s}),a&&(c.texture={url:a,size:l,pixelated:u}),c},e.resetElementIsometricData=function(t){t.classList.remove(i.NAMESPACE),function(t,e){["view","right","left","top","rotationAxis","rotationValue","texture","textureSize","texturePixelated"].forEach((function(e){t.dataset[e]&&delete t.dataset[e]}))}(t)}},854:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isometricToPoint=e.sincos=e.radian=e.round=void 0;var i=r(37);e.round=function(t){var e=Math.pow(10,i.DECIMALS);return Math.round(t*e)/e},e.radian=function(t){return t*Math.PI/180},e.sincos=function(t){return{sin:e.round(Math.sin(t)),cos:e.round(Math.cos(t))}},e.isometricToPoint=function(t){var r=t.right,o=void 0===r?0:r,n=t.left,s=void 0===n?0:n,a=t.top,l=void 0===a?0:a;return{x:e.round((o-s)*i.HSQRT3),y:e.round((o+s)/2-l)}}},361:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getViewMatrix=e.sideMatrix=e.frontMatrix=e.topMatrix=e.rotateZ=e.rotateY=e.rotateX=e.multiplyMatrices=e.multiplyMatrix=void 0;var i=r(37),o=r(854);e.multiplyMatrix=function(t,e){return t.map((function(r,i){return e[0].map((function(o,n){return r.reduce((function(r,o,s){return r+t[i][s]*e[s][n]}),0)}))}))},e.multiplyMatrices=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var i=t[0],o=1;o<t.length;o++)i=e.multiplyMatrix(i,t[o]);return i},e.rotateX=function(t){var e=o.sincos(t);return[[1,0,0],[0,e.cos,-e.sin],[0,e.sin,e.cos]]},e.rotateY=function(t){var e=o.sincos(t);return[[e.cos,0,e.sin],[0,1,0],[-e.sin,0,e.cos]]},e.rotateZ=function(t){var e=o.sincos(t);return[[e.cos,-e.sin,0],[e.sin,e.cos,0],[0,0,1]]},e.topMatrix=e.multiplyMatrices(e.rotateX(i.ROT_CMA),e.rotateZ(-i.ROT_45)),e.frontMatrix=e.multiplyMatrices(e.rotateZ(-i.ROT_60),e.rotateX(i.ROT_CMA),e.rotateZ(i.ROT_45)),e.sideMatrix=e.multiplyMatrices(e.rotateZ(i.ROT_60),e.rotateX(i.ROT_CMA),e.rotateZ(-i.ROT_45)),e.getViewMatrix=function(t,r){if(!r)switch(t){case i.VIEW.top:return e.topMatrix;case i.VIEW.front:return e.frontMatrix;case i.VIEW.side:return e.sideMatrix;default:return null}var n=o.radian(r.value);switch(t){case i.VIEW.top:switch(r.axis){case i.AXIS.top:return e.multiplyMatrix(e.topMatrix,e.rotateZ(n));case i.AXIS.left:return e.multiplyMatrix(e.topMatrix,e.rotateX(-n));default:return e.multiplyMatrix(e.topMatrix,e.rotateY(n))}case i.VIEW.front:switch(r.axis){case i.AXIS.top:return e.multiplyMatrix(e.frontMatrix,e.rotateY(n));case i.AXIS.left:return e.multiplyMatrix(e.frontMatrix,e.rotateX(n));default:return e.multiplyMatrix(e.frontMatrix,e.rotateZ(n))}case i.VIEW.side:switch(r.axis){case i.AXIS.top:return e.multiplyMatrix(e.sideMatrix,e.rotateY(n));case i.AXIS.left:return e.multiplyMatrix(e.sideMatrix,e.rotateZ(n));default:return e.multiplyMatrix(e.sideMatrix,e.rotateX(-n))}default:return null}}},821:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.kebab=void 0,e.kebab=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()}}},e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,r),o.exports}return r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(607)})()); | ||
!function(t,e){for(var r in e)t[r]=e[r];e.__esModule&&Object.defineProperty(t,"__esModule",{value:!0})}(exports,(()=>{"use strict";var t={506:(t,e,r)=>{r.r(e),r.d(e,{default:()=>o});const o=function(t){for(var e,r=0,o=0,n=t.length;n>=4;++o,n-=4)e=1540483477*(65535&(e=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+(59797*(e>>>16)<<16),r=1540483477*(65535&(e^=e>>>24))+(59797*(e>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(n){case 3:r^=(255&t.charCodeAt(o+2))<<16;case 2:r^=(255&t.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&t.charCodeAt(o)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)}},158:function(t,e,r){var o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var n=r(37),a=r(539),i=r(995),s=function(){function t(){this._elements=new Map,this._classes=new Map,this._styles=new i.Styles}return t.prototype.removeClasses=function(t,e){t.classList.remove(e);var r=this._classes.get(e),o=r.findIndex((function(e){return e===t}));r.splice(o,1),0===r.length&&(this._classes.delete(e),this._styles.remove(e))},t.prototype.process=function(t,e){var r=this._elements.get(t),o=this._styles.getRuleData(e);if(r){if(r.selector===o.selector)return;this.removeClasses(t,r.selector)}t.classList.add(o.selector);var n=this._classes.get(o.selector);n?n.push(t):(this._styles.insert(o.selector,o.declaration),this._classes.set(o.selector,[t])),this._elements.set(t,{plane:e,selector:o.selector,rule:o.rule})},t.prototype.addElement=function(t){var e=a.getPlaneFromElement(t);this.process(t,e)},t.prototype.removeElement=function(t){a.resetElementIsometricData(t);var e=this._elements.get(t);e&&(this._elements.delete(t),this.removeClasses(t,e.selector))},t.prototype.setElementView=function(t,e){if(e===n.VIEW.top||e===n.VIEW.front||e===n.VIEW.side){var r=this._elements.get(t);this.process(t,r?o(o({},r.plane),{view:e}):{view:e,parentRotations:a.getParentRotations(t)})}},t.prototype.setElementPosition=function(t,e){if(+e.right||+e.left||+e.top){var r=this._elements.get(t);this.process(t,r?o(o({},r.plane),{position:o(o({},r.plane.position),e)}):{position:e,parentRotations:a.getParentRotations(t)})}},t.prototype.setElementRotation=function(t,e){if((e.axis===n.AXIS.right||e.axis===n.AXIS.left||e.axis===n.AXIS.top)&&+e.value){var r=this._elements.get(t);this.process(t,r?o(o({},r.plane),{rotation:e}):{rotation:e,parentRotations:a.getParentRotations(t)})}},t.prototype.setElementTexture=function(t,e){if(!("string"!=typeof e.url||e.size&&"string"!=typeof e.size||e.pixelated&&"boolean"!=typeof e.pixelated)){var r=this._elements.get(t);this.process(t,r?o(o({},r.plane),{texture:o(o({},r.plane.texture),e)}):{texture:e,parentRotations:a.getParentRotations(t)})}},t}();e.default=new s},995:function(t,e,r){var o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var n=r(506),a=r(37),i=r(821),s=r(854),l=r(361),u=function(){function t(){this._style=null,this.scale=s.round(a.SCALE),this.P50="50%",this.transformBefore="translate(-"+this.P50+", -"+this.P50+")",this.tranformAfterTop="translate(-"+this.P50+", "+this.P50+")",this.transformAfterFront="translate(-"+this.P50+", -"+this.P50+")",this.transformAfterSide="translate("+this.P50+", -"+this.P50+")",this.baseDeclarations={position:"absolute"},this.transformOriginDeclarations={transformOrigin:this.P50+" "+this.P50,MsTransformOrigin:this.P50+" "+this.P50,WebkitTransformOrigin:this.P50+" "+this.P50}}return Object.defineProperty(t.prototype,"sheet",{get:function(){return this._style?this._style.sheet:null},enumerable:!1,configurable:!0}),t.prototype.getTransform=function(t,e,r){var o=l.getViewMatrix(t,e,r);if(!o)return null;var n="matrix("+s.round(o[0][0])+","+s.round(o[1][0])+","+s.round(o[0][1])+","+s.round(o[1][1])+",0,0)",i=this.transformBefore+" "+n+" scale("+this.scale+")";switch(t){case a.VIEW.top:return i+" "+this.tranformAfterTop;case a.VIEW.front:return i+" "+this.transformAfterFront;case a.VIEW.side:return i+" "+this.transformAfterSide}},t.prototype.declarationString=function(t){var e=this;return Object.entries(t).reduce((function(t,r){return Array.isArray(r[1])?t+"\n "+r[1].map((function(t){return e.declarationString(t)})).join("\n"):t+"\n "+i.kebab(r[0])+": "+r[1]+";"}),"")},t.prototype.tranformPlaneToRule=function(t){var e=this.getTransform(t.view,t.parentRotations,t.rotation),r=e?o(o(o({},this.baseDeclarations),this.transformOriginDeclarations),{transform:e,MsTransform:e,WebkitTransform:e}):o({},this.baseDeclarations);if(t.position){var n=s.isometricToPoint(t.position,t.parentRotations);r.left=n.x+"px",r.top=n.y+"px"}return t.texture&&(r.backgroundImage='url("'+t.texture.url+'")',r.backgroundSize=t.texture.size||"cover",t.texture.pixelated&&(r.MsInterpolationMode="nearest-neighbor",r.imageRendering="pixelated",r.fallbacks=[{imageRendering:"crisp-edges"}])),r},t.prototype.init=function(){this._style=document.createElement("style"),this._style.dataset.isometric="",document.getElementsByTagName("head")[0].appendChild(this._style)},t.prototype.getRule=function(t){return this.tranformPlaneToRule(t)},t.prototype.getDeclarationString=function(t){return this.declarationString(t)},t.prototype.getSelector=function(t){return a.NAMESPACE+"-"+n.default(t)},t.prototype.getRuleData=function(t){var e=this.getRule(t),r=this.getDeclarationString(e);return{rule:e,declaration:r,selector:this.getSelector(r)}},t.prototype.insert=function(t,e){this.sheet||this.init(),this.sheet.insertRule("."+t+" {\n"+e+"\n}")},t.prototype.remove=function(t){var e=this;Array.prototype.some.call(this.sheet.cssRules,(function(r,o){return!(!r||r.selectorText.slice(1)!==t||(e.sheet.deleteRule(o),0))}))},t}();e.Styles=u},37:(t,e)=>{var r,o;Object.defineProperty(e,"__esModule",{value:!0}),e.TYPE_UNDEFINED=e.AXIS=e.VIEW=e.ROT_CMA=e.ROT_45=e.ROT_60=e.SCALE=e.HSQRT3=e.DECIMALS=e.NAMESPACE=void 0,e.NAMESPACE="isometric",e.DECIMALS=6,e.HSQRT3=+(Math.sqrt(3)/2).toFixed(e.DECIMALS),e.SCALE=Math.sqrt(1.5),e.ROT_60=Math.PI/3,e.ROT_45=Math.PI/4,e.ROT_CMA=Math.atan(Math.SQRT2),(o=e.VIEW||(e.VIEW={})).top="top",o.front="front",o.side="side",(r=e.AXIS||(e.AXIS={})).right="right",r.left="left",r.top="top",e.TYPE_UNDEFINED="undefined"},607:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IsometricCSS=void 0;var o=r(37),n=r(158);e.IsometricCSS={processDOM:function(){Array.prototype.forEach.call(document.querySelectorAll("."+o.NAMESPACE),(function(t){n.default.addElement(t)}))},processElement:function(t){n.default.addElement(t)},resetElement:function(t){n.default.removeElement(t)},setView:function(t,e){n.default.setElementView(t,e)},setRotation:function(t,e){n.default.setElementRotation(t,e)},setPosition:function(t,e){n.default.setElementPosition(t,e)},setTexture:function(t,e){n.default.setElementTexture(t,e)}},typeof window!==o.TYPE_UNDEFINED&&typeof document!==o.TYPE_UNDEFINED&&(window.IsometricCSS=e.IsometricCSS,window.addEventListener("DOMContentLoaded",(function(){e.IsometricCSS.processDOM()})))},539:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resetElementIsometricData=e.getPlaneFromElement=e.getParentRotations=void 0;var o=r(37);e.getParentRotations=function(t){for(var e=[];t.parentElement&&t.parentElement!==document.documentElement;){var r=t.parentElement;r.classList.contains(o.NAMESPACE)&&!r.dataset.view&&r.dataset.rotationAxis&&e.push({axis:r.dataset.rotationAxis,value:+(r.dataset.rotationValue||0)}),t=t.parentElement}return e},e.getPlaneFromElement=function(t){var r=t.dataset.view?t.dataset.view:null,o=+(t.dataset.right||0),n=+(t.dataset.left||0),a=+(t.dataset.top||0),i=t.dataset.rotationAxis?t.dataset.rotationAxis:null,s=+(t.dataset.rotationValue||0),l=t.dataset.texture,u=t.dataset.textureSize||"cover",c="true"===t.dataset.texturePixelated,f={parentRotations:e.getParentRotations(t)};return r&&(f.view=r),(o||n||a)&&(f.position={right:o,left:n,top:a}),i&&s&&(f.rotation={axis:i,value:s}),l&&(f.texture={url:l,size:u,pixelated:c}),f},e.resetElementIsometricData=function(t){t.classList.remove(o.NAMESPACE),function(t,e){["view","right","left","top","rotationAxis","rotationValue","texture","textureSize","texturePixelated"].forEach((function(e){t.dataset[e]&&delete t.dataset[e]}))}(t)}},854:function(t,e,r){var o=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var o=Array(t),n=0;for(e=0;e<r;e++)for(var a=arguments[e],i=0,s=a.length;i<s;i++,n++)o[n]=a[i];return o};Object.defineProperty(e,"__esModule",{value:!0}),e.isometricToPoint=e.rotatePoint=e.sincos=e.radian=e.round=void 0;var n=r(37);e.round=function(t){var e=Math.pow(10,n.DECIMALS);return Math.round(t*e)/e},e.radian=function(t){return t*Math.PI/180},e.sincos=function(t){return{sin:e.round(Math.sin(t)),cos:e.round(Math.cos(t))}},e.rotatePoint=function(t,r,o){var n=Math.sqrt(Math.pow(t,2)+Math.pow(r,2)),a=Math.atan2(r,t)+e.radian(o);return{x:Math.cos(a)*n,y:Math.sin(a)*n}},e.isometricToPoint=function(t,r){var a=t.right,i=void 0===a?0:a,s=t.left,l=void 0===s?0:s,u=t.top,c=void 0===u?0:u;return r&&r.length&&o(r).reverse().forEach((function(t){switch(t.axis){case n.AXIS.top:var r=e.rotatePoint(i,l,t.value);i=r.x,l=r.y;break;case n.AXIS.right:r=e.rotatePoint(l,c,t.value),l=r.x,c=r.y;break;case n.AXIS.left:r=e.rotatePoint(c,i,t.value),c=r.x,i=r.y}})),{x:e.round((i-l)*n.HSQRT3),y:e.round((i+l)/2-c)}}},361:function(t,e,r){var o=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var o=Array(t),n=0;for(e=0;e<r;e++)for(var a=arguments[e],i=0,s=a.length;i<s;i++,n++)o[n]=a[i];return o};Object.defineProperty(e,"__esModule",{value:!0}),e.getViewMatrix=e.rotationToRotationMatrix=e.sideMatrix=e.frontMatrix=e.topMatrix=e.rotateZ=e.rotateY=e.rotateX=e.multiplyMatrices=e.multiplyMatrix=void 0;var n=r(37),a=r(854);e.multiplyMatrix=function(t,e){return t.map((function(r,o){return e[0].map((function(n,a){return r.reduce((function(r,n,i){return r+t[o][i]*e[i][a]}),0)}))}))},e.multiplyMatrices=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=1;n<t.length;n++)o=e.multiplyMatrix(o,t[n]);return o},e.rotateX=function(t){var e=a.sincos(t);return[[1,0,0],[0,e.cos,-e.sin],[0,e.sin,e.cos]]},e.rotateY=function(t){var e=a.sincos(t);return[[e.cos,0,e.sin],[0,1,0],[-e.sin,0,e.cos]]},e.rotateZ=function(t){var e=a.sincos(t);return[[e.cos,-e.sin,0],[e.sin,e.cos,0],[0,0,1]]},e.topMatrix=e.multiplyMatrices(e.rotateX(n.ROT_CMA),e.rotateZ(-n.ROT_45)),e.frontMatrix=e.multiplyMatrices(e.rotateZ(-n.ROT_60),e.rotateX(n.ROT_CMA),e.rotateZ(n.ROT_45)),e.sideMatrix=e.multiplyMatrices(e.rotateZ(n.ROT_60),e.rotateX(n.ROT_CMA),e.rotateZ(-n.ROT_45)),e.rotationToRotationMatrix=function(t,r){var o=a.radian(r.value);switch(t){case n.VIEW.top:switch(r.axis){case n.AXIS.top:return e.rotateZ(o);case n.AXIS.left:return e.rotateX(-o);case n.AXIS.right:return e.rotateY(o);default:return null}case n.VIEW.front:switch(r.axis){case n.AXIS.top:return e.rotateY(o);case n.AXIS.left:return e.rotateX(o);case n.AXIS.right:return e.rotateZ(o);default:return null}case n.VIEW.side:switch(r.axis){case n.AXIS.top:return e.rotateY(o);case n.AXIS.left:return e.rotateZ(o);case n.AXIS.right:return e.rotateX(-o);default:return null}default:return null}},e.getViewMatrix=function(t,r,a){var i=[];r.forEach((function(r){var o=e.rotationToRotationMatrix(t,r);o&&i.push(o)}));var s=a?e.rotationToRotationMatrix(t,a):null;switch(s&&i.push(s),t){case n.VIEW.top:return e.multiplyMatrices.apply(void 0,o([e.topMatrix],i));case n.VIEW.front:return e.multiplyMatrices.apply(void 0,o([e.frontMatrix],i));case n.VIEW.side:return e.multiplyMatrices.apply(void 0,o([e.sideMatrix],i))}return null}},821:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.kebab=void 0,e.kebab=function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()}}},e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={exports:{}};return t[o].call(n.exports,n,n.exports,r),n.exports}return r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(607)})()); |
{ | ||
"name": "isometric-css", | ||
"version": "2.0.0", | ||
"description": "A JavaScript library to build isometric projections using HTML elements and CSS classes", | ||
"version": "2.1.0", | ||
"description": "A lightweight JavaScript library to build isometric projections using CSS classes", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "isometric", |
<p align="center"> | ||
<a href="https://github.com/elchininet/isometric-css"> | ||
<img src="./docs-src/src/images/isometric-css.png?raw=true" width="400" title="isometric" /> | ||
<img src="./docs-src/src/images/isometric-css.png?raw=true" width="400" title="isometric-css" /> | ||
</a> | ||
@@ -16,3 +16,3 @@ <br> | ||
<a href="https://elchininet.github.io/isometric-css/"> | ||
<img src="./docs-src/src/images/isometric.png?raw=true" width="838" title="isometric" /> | ||
<img src="./docs-src/src/images/isometric.png?raw=true" width="838" title="isometric-css" /> | ||
</a> | ||
@@ -19,0 +19,0 @@ |
@@ -1,3 +0,4 @@ | ||
import { Plane } from '../@types'; | ||
import { Plane, Rotation } from '../@types'; | ||
export declare const getParentRotations: (element: HTMLElement) => Rotation[]; | ||
export declare const getPlaneFromElement: (element: HTMLElement) => Plane; | ||
export declare const resetElementIsometricData: (element: HTMLElement) => void; |
@@ -1,5 +0,6 @@ | ||
import { Point, SinCos, IsometricPosition } from '../@types'; | ||
import { Point, Rotation, SinCos, IsometricPosition } from '../@types'; | ||
export declare const round: (n: number) => number; | ||
export declare const radian: (a: number) => number; | ||
export declare const sincos: (r: number) => SinCos; | ||
export declare const isometricToPoint: (position: IsometricPosition) => Point; | ||
export declare const rotatePoint: (x: number, y: number, rotate: number) => Point; | ||
export declare const isometricToPoint: (position: IsometricPosition, rotations: Rotation[]) => Point; |
@@ -10,2 +10,3 @@ import { Matrix, View, Rotation } from '../@types'; | ||
export declare const sideMatrix: Matrix; | ||
export declare const getViewMatrix: (view: View, rotation?: Rotation) => Matrix | null; | ||
export declare const rotationToRotationMatrix: (view: View, rotation: Rotation) => Matrix | null; | ||
export declare const getViewMatrix: (view: View, parentRotations: Rotation[], rotation?: Rotation) => Matrix | null; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55552
104
0