@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
2 lines (1 loc) • 1.76 kB
JavaScript
import{BoundingBox as t}from"../core/shape/bounding-box.js";import{TYPE_FLOAT32 as e,SEMANTIC_ATTR0 as s}from"../platform/graphics/constants.js";import{VertexBuffer as r}from"../platform/graphics/vertex-buffer.js";import{VertexFormat as i}from"../platform/graphics/vertex-format.js";class o{constructor(t){this.used=!1,2===arguments.length&&(t=arguments[1]),this.options=t,this._name=t.name,this._defaultWeight=t.defaultWeight||0,this._aabb=t.aabb,this.deltaPositions=t.deltaPositions}destroy(){var t,e,s,r;null==(t=this._vertexBufferPositions)||t.destroy(),this._vertexBufferPositions=null,null==(e=this._vertexBufferNormals)||e.destroy(),this._vertexBufferNormals=null,null==(s=this.texturePositions)||s.destroy(),this.texturePositions=null,null==(r=this.textureNormals)||r.destroy(),this.textureNormals=null}get name(){return this._name}get defaultWeight(){return this._defaultWeight}get aabb(){return this._aabb||(this._aabb=new t,this.deltaPositions&&this._aabb.compute(this.deltaPositions)),this._aabb}get morphPositions(){return!!this._vertexBufferPositions||!!this.texturePositions}get morphNormals(){return!!this._vertexBufferNormals||!!this.textureNormals}clone(){return new o(this.options)}_postInit(){this.options.preserveData||(this.options=null),this.used=!0}_initVertexBuffers(t){const e=this.options;this._vertexBufferPositions=this._createVertexBuffer(t,e.deltaPositions,e.deltaPositionsType),this._vertexBufferNormals=this._createVertexBuffer(t,e.deltaNormals,e.deltaNormalsType),this._vertexBufferPositions&&(this.deltaPositions=this._vertexBufferPositions.lock())}_createVertexBuffer(t,o,n=e){if(o){return new r(t,new i(t,[{semantic:s,components:3,type:n}]),o.length/3,{data:o})}return null}_setTexture(t,e){this[t]=e}}export{o as MorphTarget};