UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 689 B
import{Vec2 as s}from"../../core/math/vec2.js";import{calculateTangents as t}from"./geometry-utils.js";import{Geometry as e}from"./geometry.js";class n extends e{constructor(e={}){var n,o,r;super();const l=null!=(n=e.halfExtents)?n:new s(.5,.5),h=null!=(o=e.widthSegments)?o:5,i=null!=(r=e.lengthSegments)?r:5,u=[],m=[],p=[],c=[];let a=0;for(let s=0;s<=h;s++)for(let t=0;t<=i;t++){const e=-l.x+2*l.x*s/h,n=0,o=-(-l.y+2*l.y*t/i),r=s/h,g=t/i;u.push(e,n,o),m.push(0,1,0),p.push(r,1-g),s<h&&t<i&&(c.push(a+i+1,a+1,a),c.push(a+i+1,a+i+2,a+1)),a++}this.positions=u,this.normals=m,this.uvs=p,this.uvs1=p,this.indices=c,e.calculateTangents&&(this.tangents=t(u,m,p,c))}}export{n as PlaneGeometry};