UNPKG

@tomorrowevening/hermes

Version:

An extendable set of Web Tools controlled via a separate window for non-intereference with content.

2 lines (1 loc) 5.38 kB
"use strict";var g=Object.create;var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var P=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of M(i))!v.call(n,t)&&t!==e&&b(n,t,{get:()=>i[t],enumerable:!(s=O(i,t))||s.enumerable});return n};var k=(n,i,e)=>(e=n!=null?g(A(n)):{},P(i||!n||!n.__esModule?b(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tomorrowevening/theatre-core"),y=require("react");let m;function w(){const[n,i]=y.useState(m);return y.useEffect(()=>{m||import("@tomorrowevening/theatre-studio").then(e=>{m=e.default,m.initialize(),m.ui.hide(),i(m)})},[]),n}function S(n,i,e,s){s.sheetObject(n,i,{transform:{position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},visible:e.visible}},t=>{const a=t.transform;e.position.copy(a.position),e.rotation.copy(a.rotation),e.scale.copy(a.scale),e.visible=a.visible})}const z=["allowOverride","alphaHash","alphaTest","alphaToCoverage","blendAlpha","blendColor","blendDst","blendDstAlpha","blendEquation","blendEquationAlpha","blendSrc","blendSrcAlpha","blending","clipIntersection","clipShadows","clipping","clippingPlanes","colorWrite","combine","defaultAttributeValues","defines","depthFunc","depthTest","depthWrite","dithering","extensions","fog","forceSinglePass","fragmentShader","glslVersion","id","index0AttributeName","index1AttributeName","index2AttributeName","index3AttributeName","index4AttributeName","isMaterial","lights","linewidth","name","needsUpdate","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","precision","premultipliedAlpha","shadowSide","side","stencilFail","stencilFunc","stencilFuncMask","stencilRef","stencilWrite","stencilWriteMask","stencilZFail","stencilZPass","toneMapped","transparent","type","uniformsGroups","uniformsNeedUpdate","userData","uuid","version","vertexColors","vertexShader","visible","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin"];function f(n){const i=typeof n;if(n===null||n.isTexture)return"texture";if(i==="boolean")return"boolean";if(i==="number")return"number";if(i==="string")return"string";if(i==="object"){if(n.isColor)return"color";if(n.isVector2)return"vector2";if(n.isVector3)return"vector3";if(n.isVector4)return"vector4";if(n.isMatrix2)return"matrix2";if(n.isMatrix3)return"matrix3";if(n.isMatrix4)return"matrix4";if(n.isEuler)return"euler";if(Array.isArray(n))return"array"}return"object"}function d(n){const i=[];for(const s in n){const t=z.find(o=>o===s),a=s.indexOf("_")===0||s.indexOf("is")===0;if(!(t||a))if(s==="uniforms"){const o=n.uniforms;for(const c in o){const p=o[c].value,u=f(p);u==="array"||u==="object"||i.push({name:`uniforms.${c}.value`,type:u,value:p})}}else{const o=f(n[s]);i.push({name:s,type:o,value:n[s]})}}return i.filter(s=>s.type!=="array"&&s.type!=="object"&&s.type!=="texture")}function x(n){const i={},e={nudgeMultiplier:.01};return n.forEach(s=>{let t=s.value;switch(s.type){case"color":t=r.types.rgba({r:t.r,g:t.g,b:t.b,a:1});break;case"number":t=r.types.number(t,e);break;case"euler":case"vector3":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e)};break;case"vector2":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e)};break;case"vector4":t={x:r.types.number(t.x,e),y:r.types.number(t.y,e),z:r.types.number(t.z,e),w:r.types.number(t.w,e)};break;case"matrix2":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e)};break;case"matrix3":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e)};break;case"matrix4":t={0:r.types.number(t.elements[0],e),1:r.types.number(t.elements[1],e),2:r.types.number(t.elements[2],e),3:r.types.number(t.elements[3],e),4:r.types.number(t.elements[4],e),5:r.types.number(t.elements[5],e),6:r.types.number(t.elements[6],e),7:r.types.number(t.elements[7],e),8:r.types.number(t.elements[8],e),9:r.types.number(t.elements[9],e),10:r.types.number(t.elements[10],e),11:r.types.number(t.elements[11],e),12:r.types.number(t.elements[12],e),13:r.types.number(t.elements[13],e),14:r.types.number(t.elements[14],e),15:r.types.number(t.elements[15],e)};break}if(s.name.includes(".")){const a=s.name.split(".");let l=i;for(let o=0;o<a.length-1;o++){const c=a[o];l[c]||(l[c]={}),l=l[c]}l[a[a.length-1]]=t}else i[s.name]=t}),i}function h(n,i,e){i.forEach(s=>{if(n[s.name]!==void 0)switch(s.type){case"boolean":case"number":n[s.name]=e.material[s.name];break;case"color":case"euler":case"matrix2":case"matrix3":case"matrix4":case"vector2":case"vector3":case"vector4":n[s.name].copy(e.material[s.name]);break}})}function T(n,i,e,s){if(!e.isMaterial)return;const t=d(e),a=x(t);s.sheetObject(n,i,{material:a},l=>{h(e,t,l)})}exports.animateObjectMaterial=T;exports.animateObjectTransform=S;exports.applyObjectMaterial=h;exports.getObjectMaterialObject=x;exports.getObjectMaterialProps=d;exports.useStudio=w;