Files

1 line
12 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,741872,e=>{"use strict";let t=(e,t)=>{};e.s(["INVALID_GHOST_COLOR",0,0xef4444,"VALID_GHOST_COLOR",0,2278750,"applyGhost",0,function(e,r){let n=r?.invalid??!1,i=!n&&(r?.valid??!1),o=[];return e.traverse(e=>{if(e.raycast=t,!e.isMesh||"cutout"===e.name)return;let r=e.material,a=Array.isArray(r),l=e=>{if(!1===e.visible)return null;let t=e.clone();return t.transparent=!0,t.depthWrite=!1,n?(t.color?.setHex(0xef4444),t.emissive?.setHex(0xef4444),t.opacity=.4):i?(t.color?.setHex(2278750),t.emissive?.setHex(2278750),t.opacity=.45):t.opacity=.5,o.push(t),t};if(a){let t=r.map(l).filter(e=>null!==e);t.length>0&&(e.material=t)}else{let t=l(r);t&&(e.material=t)}}),()=>{for(let e of o)e.dispose()}}])},960689,e=>{"use strict";e.i(958123);var t=e.i(312580);e.i(592888);var r=e.i(810741),n=e.i(190072),i=e.i(913797),o=e.i(865181);e.s(["createRelativeRoofDrag",0,function(e){let r=null,a=(e,r,i)=>{if(r===i.id)return e;let o=r?t.sceneRegistry.nodes.get(r):null,a=t.sceneRegistry.nodes.get(i.id);if(!(o&&a))return e;let l=o.localToWorld(new n.Vector3(...e));return a.worldToLocal(l),[l.x,l.y,l.z]};return{resolve(t){let n=(0,i.resolveRoofSegmentHit)(t.node,t.position[0],t.position[1],t.position[2]);if(!n)return null;if(!r||r.segmentId!==n.segment.id){var l,s;let t=(l=n.segment,(s=r)?a(s.current,s.segmentId,l):e.roofSegmentId===l.id?e.position:a(e.position,e.roofSegmentId,l));r={segmentId:n.segment.id,anchor:[n.localX,n.localZ],start:t,current:t,surfaceOffsetY:t[1]-(0,o.getSurfaceY)(t[0],t[2],n.segment)}}let u=r.start[0]+(n.localX-r.anchor[0]),d=r.start[2]+(n.localZ-r.anchor[1]),c=(0,o.getSurfaceY)(u,d,n.segment)+r.surfaceOffsetY;return r.current=[u,c,d],{segment:n.segment,localX:u,localY:c,localZ:d,hit:n}}}},"roofSegmentLocalToBuildingLocal",0,function(e,i){let o=t.sceneRegistry.nodes.get(e);if(!o)return i;let a=o.localToWorld(new n.Vector3(...i)),l=r.useViewer.getState().selection.buildingId,s=l?t.sceneRegistry.nodes.get(l):null;return s&&s.worldToLocal(a),[a.x,a.y,a.z]},"snapRelativeRoofDragTarget",0,function(e,t=!1){if(t)return e;let r=.05*Math.round(e.localX/.05),n=.05*Math.round(e.localZ/.05),i=e.localY-(0,o.getSurfaceY)(e.localX,e.localZ,e.segment),a=(0,o.getSurfaceY)(r,n,e.segment)+i;return{...e,localX:r,localY:a,localZ:n}}])},297878,e=>{"use strict";var t=e.i(843476);e.i(958123);var r=e.i(787542),n=e.i(312580);e.i(818350);var i=e.i(959110),o=e.i(271645),a=e.i(190072);e.s(["RoofAttachmentFallbackPreview",0,function({activeBuildingId:e,ghost:l,isValidRoofTarget:s,lift:u=0,onInvalidTarget:d,size:c,validTarget:f="roof"}){let[m,p]=(0,o.useState)(null),g=(0,o.useRef)(null),h=(0,o.useRef)(new a.Vector3),v=(0,o.useRef)(s),x=(0,o.useRef)(d);return(v.current=s,x.current=d,(0,o.useEffect)(()=>{if(!e){p(null),g.current=null;return}let t=e=>{g.current=e,p(null)},i=(e,t,r)=>{p([e,t+u,r]),x.current?.()},o=r=>{if(v.current?.(r)===!1){let t,o;return void(t=h.current.set(...r.position),(o=n.sceneRegistry.nodes.get(e))&&(o.updateWorldMatrix(!0,!1),o.worldToLocal(t)),i(t.x,0,t.z))}t(r.nativeEvent)},a=e=>t(e.nativeEvent),l=e=>{if(e.nativeEvent===g.current)return;let[t,r,n]=e.localPosition;i(t,r,n)};return"roof"===f?(r.emitter.on("roof:enter",o),r.emitter.on("roof:move",o)):(r.emitter.on("gutter:enter",a),r.emitter.on("gutter:move",a)),r.emitter.on("grid:move",l),()=>{"roof"===f?(r.emitter.off("roof:enter",o),r.emitter.off("roof:move",o)):(r.emitter.off("gutter:enter",a),r.emitter.off("gutter:move",a)),r.emitter.off("grid:move",l)}},[e,u,f]),e&&m)?l?(0,t.jsx)("group",{position:m,children:l}):c?(0,t.jsx)(i.DragBoundingBox,{color:0xef4444,nodeId:"roof-attachment-fallback",position:m,size:c}):null:null}])},157610,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(190072),i=e.i(741872),o=e.i(142634);let a=new n.MeshStandardMaterial({color:8947848,transparent:!0,opacity:.45,depthWrite:!1}),l=new n.MeshStandardMaterial({color:i.INVALID_GHOST_COLOR,emissive:i.INVALID_GHOST_COLOR,emissiveIntensity:.12,roughness:.5,transparent:!0,opacity:.4,depthWrite:!1});e.s(["default",0,({node:e,invalid:n})=>{let i=(0,r.useMemo)(()=>(0,o.buildDormerGhostGeometry)(e),[e.width,e.depth,e.height,e.roofHeight,e.roofType,e.wallSkirtHeight]);return(0,r.useEffect)(()=>()=>i.dispose(),[i]),(0,t.jsx)("mesh",{geometry:i,material:n?l:a,raycast:()=>{}})}])},508636,657903,e=>{"use strict";var t=e.i(843476);e.i(818350);var r=e.i(204985),n=e.i(349537);e.i(592888);var i=e.i(810741),o=e.i(560099),a=e.i(271645),l=e.i(190072),s=e.i(843662),u=e.i(865181),d=e.i(946861);let c=new s.LineBasicNodeMaterial({color:8490232,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0}),f=new s.LineBasicNodeMaterial({color:0xef4444,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});function m({guide:e,unit:r}){return"badge"===e.kind?(0,t.jsx)(p,{at:e.at,pill:`= ${(0,n.formatMeasurement)(e.value,r)}`}):(0,t.jsx)(g,{from:e.from,kind:e.kind,pill:void 0===e.value?void 0:(0,n.formatMeasurement)(e.value,r),to:e.to})}function p({at:e,pill:r}){return(0,t.jsx)(o.Html,{center:!0,position:e,style:{pointerEvents:"none",userSelect:"none"},zIndexRange:[20,0],children:(0,t.jsx)("div",{className:"whitespace-nowrap rounded-[3px] px-[5px] py-[2px] font-semibold font-sans text-[11px] text-white",style:{backgroundColor:"#ec4899"},children:r})})}function g({from:e,to:n,pill:i,kind:s}){let{line:u,position:d}=(0,a.useMemo)(()=>{let e=new l.Float32BufferAttribute(new Float32Array(6),3),t=new l.BufferGeometry;t.setAttribute("position",e);let n=new l.Line(t,"align-line"===s?f:c);return n.frustumCulled=!1,n.layers.set(r.EDITOR_LAYER),n.renderOrder=1e3,{line:n,position:e}},[s]);d.setXYZ(0,e[0],e[1],e[2]),d.setXYZ(1,n[0],n[1],n[2]),d.needsUpdate=!0,(0,a.useEffect)(()=>()=>u.geometry.dispose(),[u]);let m=[(e[0]+n[0])/2,(e[1]+n[1])/2,(e[2]+n[2])/2];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("primitive",{object:u}),i?(0,t.jsx)(o.Html,{center:!0,position:m,style:{pointerEvents:"none",userSelect:"none"},zIndexRange:[20,0],children:(0,t.jsx)("div",{className:"whitespace-nowrap rounded-[3px] px-[5px] py-[2px] font-medium font-sans text-[11px] text-white",style:{backgroundColor:"#6366f1"},children:i})}):null]})}e.s(["DormerPlacementGuides",0,function({segment:e,center:r,width:n,depth:o,rotation:a,movingId:l}){let s=(0,i.useViewer)(e=>e.unit),[c,,f]=r,p=(0,u.getRoofSurfaceFaceBoundsAt)(e,c,f),g=Math.max(0,n)/2,h=Math.max(0,o)/2,v=Math.cos(a),x=Math.sin(a),M=Math.abs(v)*g+Math.abs(x)*h,y=Math.abs(x)*g+Math.abs(v)*h,R=(0,d.roofGuideBounds)(r,{width:n,depth:o,rotation:a}),w=(e,t)=>p.surfaceYAt(e,t)+.02,S=p.xIntervalAtZ(f),E=p.zIntervalAtX(c),b=[],I=(e,t,r,n,i)=>{let o=[t,w(t,r),r],a=[n,w(n,i),i],l=Math.hypot(a[0]-o[0],a[1]-o[1],a[2]-o[2]);l<.02||b.push({id:e,from:o,to:a,kind:"dimension",value:l})},T=(0,d.roofSiblingSpacing)({segment:e,movingId:l,movingBounds:R,faceKey:(0,d.roofFaceKey)(p.polygon),dimension:(e,[t,r],[n,i])=>{let o=[t,w(t,r),r],a=[n,w(n,i),i],l=Math.hypot(a[0]-o[0],a[1]-o[1],a[2]-o[2]);return l<.02?null:{id:e,from:o,to:a,kind:"dimension",value:l}},alignLine:(e,[t,r],[n,i])=>{let o=[t,w(t,r),r],a=[n,w(n,i),i];return .02>Math.hypot(a[0]-o[0],a[1]-o[1],a[2]-o[2])?null:{id:e,from:o,to:a,kind:"align-line"}},badge:(e,[t,r],n)=>n<.02?null:{id:e,at:[t,w(t,r),r],kind:"badge",value:n},measure:([e,t],[r,n])=>{let i=w(e,t),o=w(r,n);return Math.hypot(r-e,o-i,n-t)}});if(S){let[e,t]=S,r=Math.max(e,Math.min(t,c-M)),n=Math.max(e,Math.min(t,c+M));!T.blockedSides.left&&r>e+.02&&I("left",e,f,r,f),!T.blockedSides.right&&n<t-.02&&I("right",n,f,t,f)}if(E){let[e,t]=E,r=Math.max(e,Math.min(t,f-y)),n=Math.max(e,Math.min(t,f+y));!T.blockedSides.bottom&&r>e+.02&&I("back",c,e,c,r),!T.blockedSides.top&&n<t-.02&&I("front",c,n,c,t)}return b.push(...T.guides),(0,t.jsx)(t.Fragment,{children:b.map(e=>(0,t.jsx)(m,{guide:e,unit:s},e.id))})}],508636),e.i(958123);var h=e.i(787542),v=e.i(312580),x=e.i(524590),M=e.i(127541),y=e.i(960689),R=e.i(913797),w=e.i(142634);let S=new l.Matrix4,E=new l.Matrix4,b=new l.Vector3,I=new l.Quaternion,T=new l.Vector3;e.s(["useDormerPlacement",0,function(e){let t=(0,i.useViewer)(e=>e.selection.buildingId),[r,n]=(0,a.useState)(null),[o,l]=(0,a.useState)(null),[s,u]=(0,a.useState)(null),[d,c]=(0,a.useState)(e.initialRotation??0),f=(0,a.useRef)(null),m=(0,a.useRef)(e.initialRotation??0),p=(0,a.useRef)(e.relativeStart),g=(0,a.useRef)(e.onCommit);return g.current=e.onCommit,(0,a.useEffect)(()=>{if(!t)return;let e=p.current?(0,y.createRelativeRoofDrag)(p.current):null,r=!1,i=null,o=t=>e?e.resolve(t):(0,R.resolveRoofSegmentHit)(t.node,t.position[0],t.position[1],t.position[2]),a=r=>{var a;let s,d,c=r.position[0],m=r.position[2],p=Math.round(c/w.DORMER_PLACEMENT_SNAP_M)*w.DORMER_PLACEMENT_SNAP_M,g=Math.round(m/w.DORMER_PLACEMENT_SNAP_M)*w.DORMER_PLACEMENT_SNAP_M,h=f.current;r.nativeEvent?.shiftKey===!0||h&&h[0]===p&&h[1]===g||((0,M.triggerSFX)("sfx:grid-snap"),f.current=[p,g]);let x=o(r);if(!x)return;e&&(i=x);let y=(a=x.segment.id,s=v.sceneRegistry.nodes.get(t),d=v.sceneRegistry.nodes.get(a),s&&d?(s.updateWorldMatrix(!0,!1),d.updateWorldMatrix(!0,!1),E.copy(s.matrixWorld).invert(),S.multiplyMatrices(E,d.matrixWorld),S.decompose(b,I,T),{position:[b.x,b.y,b.z],quaternion:[I.x,I.y,I.z,I.w]}):null);y&&(n(y),l(x.segment),u([x.localX,x.localY,x.localZ]),r.stopPropagation())},s=t=>{if(r)return;let n=e?i??o(t):o(t);n&&(r=!0,g.current(n,m.current),(0,M.triggerSFX)("sfx:item-place"),t.stopPropagation())},d=t=>{if(r||!(0,x.consumePlacementDragRelease)(t))return;let n=e?i:null;n&&(r=!0,g.current(n,m.current),(0,M.triggerSFX)("sfx:item-place"))},A=e=>{if("r"!==e.key&&"R"!==e.key)return;let t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;let r=e.shiftKey?-1:1;m.current+=r*w.DORMER_PLACEMENT_ROTATION_STEP,c(m.current),e.preventDefault()};return h.emitter.on("roof:move",a),h.emitter.on("roof:enter",a),h.emitter.on("roof:click",s),window.addEventListener("keydown",A),window.addEventListener("pointerup",d),()=>{h.emitter.off("roof:move",a),h.emitter.off("roof:enter",a),h.emitter.off("roof:click",s),window.removeEventListener("keydown",A),window.removeEventListener("pointerup",d)}},[t]),{activeBuildingId:t??void 0,clearPreview:()=>{n(null),l(null),u(null)},segmentXform:r,hitSegment:o,hitLocal:s,ghostRotation:d}}],657903)},76254,e=>{"use strict";var t=e.i(843476);e.i(958123);var r=e.i(725867),n=e.i(34731);e.i(818350);var i=e.i(792716);e.i(592888);var o=e.i(810741),a=e.i(271645),l=e.i(297878),s=e.i(199274),u=e.i(508636),d=e.i(157610),c=e.i(657903);e.s(["default",0,()=>{let e=(0,o.useViewer)(e=>e.setSelection),f=(0,a.useMemo)(()=>r.DormerNode.parse({...s.dormerDefinition.defaults(),name:"Dormer",position:[0,0,0],rotation:0}),[]),{activeBuildingId:m,clearPreview:p,segmentXform:g,hitSegment:h,hitLocal:v,ghostRotation:x}=(0,c.useDormerPlacement)({onCommit:(t,o)=>{let a=n.useScene.getState(),l=r.DormerNode.parse({...s.dormerDefinition.defaults(),name:`Dormer ${function(e){let t=new Set;for(let r of Object.values(e)){if(!r||"object"!=typeof r||"dormer"!==r.type)continue;let e=r.name?.match(/^Dormer (\d+)$/);e?.[1]&&t.add(Number.parseInt(e[1],10))}let r=1;for(;t.has(r);)r++;return r}(a.nodes)}`,roofSegmentId:t.segment.id,parentId:t.segment.id,position:[t.localX,t.localY,t.localZ],rotation:o});a.createNode(l,t.segment.id),a.dirtyNodes.add(t.segment.id),e({selectedIds:[l.id]}),i.usePlacementPreview.getState().clear()}});return(0,a.useEffect)(()=>{let e=i.usePlacementPreview.getState();if(!(h&&v)){e.node?.id===f.id&&e.clear();return}e.set(r.DormerNode.parse({...f,parentId:h.id,position:v,roofSegmentId:h.id,rotation:x}),h)},[x,v,h,f]),(0,a.useEffect)(()=>()=>{let e=i.usePlacementPreview.getState();e.node?.id===f.id&&e.clear()},[f.id]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.RoofAttachmentFallbackPreview,{activeBuildingId:m,ghost:(0,t.jsx)(d.default,{node:f,invalid:!0}),onInvalidTarget:p}),m&&g&&v&&(0,t.jsxs)("group",{position:g.position,quaternion:g.quaternion,children:[h&&(0,t.jsx)(u.DormerPlacementGuides,{center:v,depth:f.depth,rotation:x,segment:h,width:f.width}),(0,t.jsx)("group",{position:v,children:(0,t.jsx)("group",{"rotation-y":x,children:(0,t.jsx)(d.default,{node:f})})})]})]})}])}]);