فهرست منبع

Merge pull request #9755 from avin/updatable-capsule

updatable capsule
David Catuhe 4 سال پیش
والد
کامیت
a60e1b94b9
2فایلهای تغییر یافته به همراه28 افزوده شده و 6 حذف شده
  1. 13 0
      .editorconfig
  2. 15 6
      src/Meshes/Builders/capsuleBuilder.ts

+ 13 - 0
.editorconfig

@@ -0,0 +1,13 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = crlf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = false
+
+[*.md]
+trim_trailing_whitespace = false

+ 15 - 6
src/Meshes/Builders/capsuleBuilder.ts

@@ -1,6 +1,8 @@
 import { VertexData } from "../mesh.vertexData";
 import { Vector2, Vector3, Matrix } from "../../Maths/math.vector";
 import { Mesh, _CreationDataStorage } from "../mesh";
+import { Nullable } from "../../types";
+import { Scene } from "../../scene";
 /**
  * Scripts based off of https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  * @param options the constructors options used to shape the mesh.
@@ -246,6 +248,9 @@ export interface ICreateCapsuleOptions{
 
     /** Overwrite for the bottom capSubdivisions. */
     bottomCapSubdivisions?: number;
+
+    /** Internal geometry is supposed to change once created. */
+    updatable?: boolean;
 }
 
 /**
@@ -271,18 +276,22 @@ export class CapsuleBuilder {
      * @param scene The scene the mesh is scoped to.
      * @returns Capsule Mesh
      */
-    public static CreateCapsule(name: string, options: ICreateCapsuleOptions = {
+    public static CreateCapsule(
+        name: string,
+        options: ICreateCapsuleOptions = {
             orientation : Vector3.Up(),
             subdivisions: 2,
             tessellation: 16,
             height: 1,
             radius: 0.25,
-            capSubdivisions: 6
-        }, scene: any): Mesh {
-
+            capSubdivisions: 6,
+            updatable: false,
+        },
+        scene: Nullable<Scene> = null
+    ): Mesh {
         var capsule = new Mesh(name, scene);
         var vertexData = VertexData.CreateCapsule(options);
-        vertexData.applyToMesh(capsule);
+        vertexData.applyToMesh(capsule, options.updatable);
         return capsule;
     }
-}
+}