|
@@ -4,6 +4,8 @@ import { Vector3, Vector2, Path2 } from "../Maths/math";
|
|
|
import { VertexBuffer } from "../Meshes/buffer";
|
|
|
import { Mesh } from "../Meshes/mesh";
|
|
|
import { VertexData } from "../Meshes/mesh.vertexData";
|
|
|
+import { Engine } from "../Engines/engine";
|
|
|
+import { Nullable } from "../types";
|
|
|
|
|
|
declare var earcut: any;
|
|
|
/**
|
|
@@ -154,7 +156,7 @@ export class PolygonMeshBuilder {
|
|
|
private _holes = new Array<PolygonPoints>();
|
|
|
|
|
|
private _name: string;
|
|
|
- private _scene: Scene;
|
|
|
+ private _scene: Nullable<Scene>;
|
|
|
|
|
|
private _epoints: number[] = new Array<number>();
|
|
|
private _eholes: number[] = new Array<number>();
|
|
@@ -174,13 +176,13 @@ export class PolygonMeshBuilder {
|
|
|
* Creates a PolygonMeshBuilder
|
|
|
* @param name name of the builder
|
|
|
* @param contours Path of the polygon
|
|
|
- * @param scene scene to add to
|
|
|
+ * @param scene scene to add to when creating the mesh
|
|
|
* @param earcutInjection can be used to inject your own earcut reference
|
|
|
*/
|
|
|
- constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection = earcut) {
|
|
|
+ constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection = earcut) {
|
|
|
this.bjsEarcut = earcutInjection;
|
|
|
this._name = name;
|
|
|
- this._scene = scene;
|
|
|
+ this._scene = scene || Engine.LastCreatedScene;
|
|
|
|
|
|
var points: Vector2[];
|
|
|
if (contours instanceof Path2) {
|