@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
2 lines (1 loc) • 1.22 kB
JavaScript
import{Vec3 as t}from"../../../core/math/vec3.js";import{CULLFACE_NONE as s}from"../../../platform/graphics/constants.js";import{PlaneGeometry as i}from"../../../scene/geometry/plane-geometry.js";import{TriData as e}from"../tri-data.js";import{Shape as r}from"./shape.js";class a extends r{constructor(r,a={}){super(r,a),this._cull=s,this._size=.2,this._gap=.1,this._flipped=new t,this.triData=[new e(new i)],this._createPlane()}set size(t){this._size=null!=t?t:1,this._updateTransform()}get size(){return this._size}set gap(t){this._gap=null!=t?t:0,this._updateTransform()}get gap(){return this._gap}set flipped(t){this._flipped.distance(t)<1e-6||(this._flipped.copy(t),this.entity.setLocalPosition(this._getPosition()))}get flipped(){return this._flipped}_getPosition(){const s=this._size/2+this._gap,i=new t(this._flipped.x?-s:s,this._flipped.y?-s:s,this._flipped.z?-s:s);return i[this.axis]=0,i}_createPlane(){this._createRoot("plane"),this._updateTransform(),this._addRenderMesh(this.entity,"plane",this._shading)}_updateTransform(){this.entity.setLocalPosition(this._getPosition()),this.entity.setLocalEulerAngles(this._rotation),this.entity.setLocalScale(this._size,this._size,this._size)}}export{a as PlaneShape};