PageSourceSearch

https://www.3d-editor.com/_next/static/chunks/5844.d1c777eaa27a8165.js

js 3d-editor.com collected 2026-10-02 00:49:48 UTC 5,271 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5844],{75844:function(e,t,i){i.d(t,{createClothFromSkin:function(){return h}});var o=i(12249),r=i(72079),n=i(21012),s=i(85502),a=i(38640),l=i(73724),d=i(59184),c=i(52866);function h(e,t,i,o){var h,m,p,g,f,b,v,w;let k=e.objects[i],y=null==k?void 0:k.skin;if(!(t instanceof r.TUv)||!y)throw Error("Select a mesh bound to an armature.");if("object"!==e.editorMode||e.timeline.isPlaying||e.timeline.currentFrame!==e.timeline.startFrame)throw Error("Use Object Mode, pause playback and go to the timeline Start frame first.");if(k.locked||e.collections.some(e=>e.locked&&e.objectIds.includes(i)))throw Error("Unlock the source mesh and its collection first.");if(k.physics||k.cloth||(null===(h=k.modifiers)||void 0===h?void 0:h.length)||(null===(m=k.constraints)||void 0===m?void 0:m.some(e=>e.enabled))||(null===(p=k.shapeKeys)||void 0===p?void 0:p.length)||(null===(g=t.geometry.morphAttributes.position)||void 0===g?void 0:g.length)||e.keyframes.some(e=>e.objectId===i)||e.animations.some(e=>"imported"===e.kind))throw Error("Use a source without physics, modifiers, shape keys, object keys/constraints or imported animation clips. Bone animation is supported.");let I=e.objects[y.armatureId];if(!(null==I?void 0:I.armature))throw Error("The source armature is missing.");(0,d.k)(e,I).apply(e.timeline.startFrame);let E=t.geometry,C=E.getAttribute("position"),x=E.getAttribute("skinIndex"),j=E.getAttribute("skinWeight");if(!C||!x||!j||4!==x.itemSize||4!==j.itemSize||x.count!==C.count||j.count!==C.count)throw Error("Repair missing or invalid skin buffers before creating cloth.");let M=(0,a.Bg)(E),A=M.vertices.length;if(A<9||A>4096||M.faces.length>4096)throw Error("Cloth copies require 9–4,096 vertices and at most 4,096 faces.");let N=null!==(f=E.userData.editableMeshGlToWelded)&&void 0!==f?f:Array.from({length:C.count},(e,t)=>t);if(N.length!==C.count||N.some(e=>!Number.isInteger(e)||e<0||e>=A))throw Error("Invalid skin-to-editable vertex mapping.");if(t.updateWorldMatrix(!0,!1),t.skeleton.bones.forEach(e=>e.updateWorldMatrix(!0,!1)),t.skeleton.update(),!Number.isFinite(t.matrixWorld.determinant())||0>=t.matrixWorld.determinant())throw Error("Apply mirrored or zero source scale before creating cloth.");let W=new Set,F=new Map,S=new Map;for(let e=0;e<C.count;e++){let i=N[e],o=t.getVertexPosition(e,new r.Pa4).applyMatrix4(t.matrixWorld);if(!o.toArray().every(Number.isFinite))throw Error("The posed source has invalid vertices.");let n=new Map,s=0;for(let i=0;i<4;i++){let o=j.getComponent(e,i),r=x.getComponent(e,i);if(!Number.isFinite(o)||o<0)throw Error("Invalid skin weights.");if(0===o)continue;let a=y.boneIds[r];if(!Number.isInteger(r)||!a||!I.armature.bones.some(e=>e.id===a)||!t.skeleton.bones[r])throw Error("A weighted source bone is missing.");n.set(a,(null!==(b=n.get(a))&&void 0!==b?b:0)+o),s+=o}if(Math.abs(s-1)>1e-4)throw Error("Normalize source skin weights before creating cloth.");let a=JSON.stringify([...n].sort((e,t)=>{let[i]=e,[o]=t;return i.localeCompare(o)}));if(W.has(i)){if(o.distanceTo(new r.Pa4(...M.vertices[i]))>1e-5||S.get(i)!==a)throw Error("Skin seams have conflicting weights or poses. Split or repair them before creating cloth.");continue}for(let[e,t]of(W.add(i),S.set(i,a),M.vertices[i]=o.toArray(),n)){let o=null!==(v=F.get(e))&&void 0!==v?v:new Map;o.set(i,t/s),F.set(e,o)}}if(W.size!==A||F.size>16)throw Error("Cloth copies support complete vertex mappings and at most 16 influencing bones.");let _=(0,l.It)(A,M.faces.map(e=>e.vertices)),O=new Map([...F.keys()].map((e,t)=>[e,"skin-".concat(t)])),U=[...F].map(e=>{let[t,i]=e;return{id:O.get(t),name:I.armature.bones.find(e=>e.id===t).name,pinnedVertices:[...i.keys()],pinWeights:[...i.values()],pinTopology:_}}),z=o?U.find(e=>e.id===O.get(o)):void 0;if(o&&!z)throw Error("Choose a bone group with nonzero weights.");if(z&&z.pinnedVertices.length===A&&z.pinWeights.every(e=>e>=1-1e-6))throw Error("This group pins every vertex. Choose a partial group or Free fabric, then paint an attachment mask on the copy.");let T=(0,l.Fu)({...l.hs,nativeCloth:(0,c.Ol)(),pinGroups:U,pinMode:z?"custom"
1:"none",activePinGroupId:null!==(w=null==z?void 0:z.id)&&void 0!==w?w:null,pinDriver:z?{armatureId:I.id,boneId:o,bindings:[...F.keys()].map(e=>({boneId:e,groupId:O.get(e)}))}:null}),P=(0,a.PM)(M);P.deleteAttribute("skinIndex"),P.deleteAttribute("skinWeight");let D=new r.Kj0(P,t.material),K=crypto.randomUUID(),V=(0,n.Ns)(k);return Object.assign(V,{id:K,uuid:D.uuid,name:"".concat(k.name," Cloth"),parentId:null,skin:void 0,modifiers:[],constraints:[],shapeKeys:void 0,cloth:T,clothCache:void 0,locked:!1,visible:!0,transform:{position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}}),D.name=V.name,(0,s.xo)(D,K),new u({object:D,metadata:V,index:e.objectOrder.length},i)}class u{execute(e){return!!e.restoreObject(this.snapshot,!0)}undo(e){let t=e.deleteObject(this.snapshot.metadata.id);return t&&e.selectObject(this.sourceId),t}constructor(e,t){(0,o._)(this,"snapshot",void 0),(0,o._)(this,"sourceId",void 0),(0,o._)(this,"id",void 0),(0,o._)(this,"type",void 0),(0,o._)(this,"label",void 0),this.snapshot=e,this.sourceId=t,this.id=crypto.randomUUID(),this.type="add-object",this.label="Create Cloth Copy"}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.