1 line
66 KiB
Plaintext
1 line
66 KiB
Plaintext
|
|
{"version":3,"file":"Geometry.cjs","sources":["../../src/deprecated/Geometry.js"],"sourcesContent":["import {\n Box3,\n BufferAttribute,\n BufferGeometry,\n Color,\n EventDispatcher,\n Float32BufferAttribute,\n Matrix3,\n Matrix4,\n MathUtils,\n Object3D,\n Sphere,\n Vector2,\n Vector3,\n} from 'three'\n\nconst _m1 = /* @__PURE__ */ new Matrix4()\nconst _obj = /* @__PURE__ */ new Object3D()\nconst _offset = /* @__PURE__ */ new Vector3()\n\nconst Geometry = /* @__PURE__ */ (() => {\n class Geometry extends EventDispatcher {\n static createBufferGeometryFromObject(object) {\n let buffergeometry = new BufferGeometry()\n\n const geometry = object.geometry\n\n if (object.isPoints || object.isLine) {\n const positions = new Float32BufferAttribute(geometry.vertices.length * 3, 3)\n const colors = new Float32BufferAttribute(geometry.colors.length * 3, 3)\n\n buffergeometry.setAttribute('position', positions.copyVector3sArray(geometry.vertices))\n buffergeometry.setAttribute('color', colors.copyColorsArray(geometry.colors))\n\n if (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {\n const lineDistances = new Float32BufferAttribute(geometry.lineDistances.length, 1)\n\n buffergeometry.setAttribute('lineDistance', lineDistances.copyArray(geometry.lineDistances))\n }\n\n if (geometry.boundingSphere !== null) {\n buffergeometry.boundingSphere = geometry.boundingSphere.clone()\n }\n\n if (geometry.boundingBox !== null) {\n buffergeometry.boundingBox = geometry.boundingBox.clone()\n }\n } else if (object.isMesh) {\n buffergeometry = geometry.toBufferGeometry()\n }\n\n return buffergeometry\n }\n\n constructor() {\n super()\n this.isGeometry = true\n this.uuid = MathUtils.generateUUID()\n\n this.name = ''\n this.type = 'Geometry'\n\n this.vertices = []\n this.colors = []\n this.faces = []\n this.faceVertexUvs = [[]]\n\n this.morphTargets = []\n this.morphNormals = []\n\n this.skinWeights = []\n this.skinIndices = []\n\n this.lineDistances = []\n\n this.boundingBox = null\n this.boundingSphere = null\n\n // update flags\n\n this.elementsNeedUpdate = false\n this.verticesNeedUpdate = false\n this.uvsNeedUpdate = false\n this.normalsNeedUpdate = false\n this.colorsNeedUpdate = false\n this.lineDistancesNeedUpdate = false\n this.groupsNeedUpdate = false\n }\n\n applyMatrix4(matrix) {\n const normalMatrix = new Matrix3().getNormalMatrix(matrix)\n\n for (let i = 0, il = this.vertices.length; i < il; i++) {\n const vertex = this.vertices[i]\n vertex.applyMatrix4(matrix)\n }\n\n for (let i = 0, il = this.faces.length; i < il; i++) {\n const face = this.faces[i]\n face.normal.applyMatrix3(normalMatrix).normalize()\n\n for (let j = 0, jl = face.vertexNormals.length; j < jl; j++) {\n face.vertexNormals[j].applyMatrix3(normalMatrix).normalize()\n }\n }\n\n if (this.boundingBox !== null) {\n this.computeBoundingBox()\n }\n\n if (this.boundingSphere !== null) {\n this.computeBoundingSphere()\n }\n\n this.verticesNeedUpdate = true\n this.normalsNeedUpdate = true\n\n return this\n }\n\n rotateX(angle) {\n // rotate geometry around world x-axis\n\n _m1.makeRotationX(angle)\n\n this.applyMatrix4(_m1)\n\n return this\n }\n\n rotateY(angle) {\n // rotate geometry around world y-axis\n\n _m1.makeRotationY(angle)\n\n this.applyMatrix4(_m1)\n\n return this\n }\n\n rotateZ(angle) {\n // rotate geometry around world z-axis\n\n _m1.makeRotationZ(angle)\n\n this.applyMatrix4(_m1)\n\n return this\n }\n\n translate(x, y, z) {\n // translate geometry\n\n _m1.makeTranslation(x, y, z)\n\n this.applyMatrix4(_m1)\n\n retu
|