UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 920 B
import{Vec3 as t}from"../../core/math/vec3.js";import{Quat as r}from"../../core/math/quat.js";import{Mat4 as o}from"../../core/math/mat4.js";import{Tri as e}from"../../core/shape/tri.js";import{Geometry as s}from"../../scene/geometry/geometry.js";const i=new t,n=new t,m=new t;class h{constructor(t,r=0){this._priority=0,this._transform=new o,this.tris=[],this.fromGeometry(t),this._priority=r}get transform(){return this._transform}get priority(){return this._priority}setTransform(o=new t,e=new r,s=new t){this.transform.setTRS(o,e,s)}fromGeometry(t){var r,o;if(!(t&&t instanceof s))throw new Error("No geometry provided.");const h=null!=(r=t.positions)?r:[],c=null!=(o=t.indices)?o:[];this.tris=[];for(let t=0;t<c.length;t+=3){const r=c[t],o=c[t+1],s=c[t+2];i.set(h[3*r],h[3*r+1],h[3*r+2]),n.set(h[3*o],h[3*o+1],h[3*o+2]),m.set(h[3*s],h[3*s+1],h[3*s+2]);const f=new e(i,n,m);this.tris.push(f)}}}export{h as TriData};