|
@@ -1,5 +1,5 @@
|
|
|
import * as React from "react";
|
|
|
-import { Mesh, Observable } from "babylonjs";
|
|
|
+import { Mesh, Observable, VertexBuffer, Color3, Vector3, MeshBuilder, Tools, PhysicsImpostor, Scene } from "babylonjs";
|
|
|
import { PropertyChangedEvent } from "../../../../propertyChangedEvent";
|
|
|
import { LineContainerComponent } from "../../../lineContainerComponent";
|
|
|
import { TextLineComponent } from "../../../lines/textLineComponent";
|
|
@@ -12,10 +12,10 @@ import { FloatLineComponent } from "../../../lines/floatLineComponent";
|
|
|
import { LockObject } from "../lockObject";
|
|
|
|
|
|
interface IMeshPropertyGridComponentProps {
|
|
|
- mesh: Mesh,
|
|
|
- lockObject: LockObject,
|
|
|
- onSelectionChangedObservable?: Observable<any>,
|
|
|
- onPropertyChangedObservable?: Observable<PropertyChangedEvent>
|
|
|
+ mesh: Mesh;
|
|
|
+ lockObject: LockObject;
|
|
|
+ onSelectionChangedObservable?: Observable<any>;
|
|
|
+ onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
|
|
}
|
|
|
|
|
|
export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGridComponentProps, { displayNormals: boolean, renderNormalVectors: boolean }> {
|
|
@@ -23,7 +23,7 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
super(props);
|
|
|
const mesh = this.props.mesh;
|
|
|
|
|
|
- this.state = { displayNormals: false, renderNormalVectors: mesh.metadata && mesh.metadata.normalLines }
|
|
|
+ this.state = { displayNormals: false, renderNormalVectors: mesh.metadata && mesh.metadata.normalLines };
|
|
|
}
|
|
|
|
|
|
renderNormalVectors() {
|
|
@@ -38,20 +38,20 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- var normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
|
|
|
- var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
|
|
|
+ var normals = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
|
+ var positions = mesh.getVerticesData(VertexBuffer.PositionKind);
|
|
|
|
|
|
- const color = BABYLON.Color3.White();
|
|
|
+ const color = Color3.White();
|
|
|
const size = mesh.getBoundingInfo().diagonalLength * 0.05;
|
|
|
|
|
|
var lines = [];
|
|
|
for (var i = 0; i < normals!.length; i += 3) {
|
|
|
- var v1 = BABYLON.Vector3.FromArray(positions!, i);
|
|
|
- var v2 = v1.add(BABYLON.Vector3.FromArray(normals!, i).scaleInPlace(size));
|
|
|
+ var v1 = Vector3.FromArray(positions!, i);
|
|
|
+ var v2 = v1.add(Vector3.FromArray(normals!, i).scaleInPlace(size));
|
|
|
lines.push([v1, v2]);
|
|
|
}
|
|
|
|
|
|
- var normalLines = BABYLON.MeshBuilder.CreateLineSystem("normalLines", { lines: lines }, scene);
|
|
|
+ var normalLines = MeshBuilder.CreateLineSystem("normalLines", { lines: lines }, scene);
|
|
|
normalLines.color = color;
|
|
|
normalLines.parent = mesh;
|
|
|
|
|
@@ -81,7 +81,7 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
|
|
|
if (!(BABYLON as any).NormalMaterial) {
|
|
|
this.setState({ displayNormals: true });
|
|
|
- BABYLON.Tools.LoadScript("https://preview.babylonjs.com/materialsLibrary/babylonjs.materials.js", () => {
|
|
|
+ Tools.LoadScript("https://preview.babylonjs.com/materialsLibrary/babylonjs.materials.js", () => {
|
|
|
this.displayNormals();
|
|
|
});
|
|
|
return;
|
|
@@ -107,27 +107,27 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
}
|
|
|
|
|
|
const mesh = this.props.mesh;
|
|
|
- this.props.onSelectionChangedObservable.notifyObservers(mesh.material)
|
|
|
+ this.props.onSelectionChangedObservable.notifyObservers(mesh.material);
|
|
|
}
|
|
|
|
|
|
convertPhysicsTypeToString(): string {
|
|
|
const mesh = this.props.mesh;
|
|
|
switch (mesh.physicsImpostor!.type) {
|
|
|
- case BABYLON.PhysicsImpostor.NoImpostor:
|
|
|
+ case PhysicsImpostor.NoImpostor:
|
|
|
return "No impostor";
|
|
|
- case BABYLON.PhysicsImpostor.SphereImpostor:
|
|
|
+ case PhysicsImpostor.SphereImpostor:
|
|
|
return "Sphere";
|
|
|
- case BABYLON.PhysicsImpostor.BoxImpostor:
|
|
|
+ case PhysicsImpostor.BoxImpostor:
|
|
|
return "Box";
|
|
|
- case BABYLON.PhysicsImpostor.PlaneImpostor:
|
|
|
+ case PhysicsImpostor.PlaneImpostor:
|
|
|
return "Plane";
|
|
|
- case BABYLON.PhysicsImpostor.MeshImpostor:
|
|
|
+ case PhysicsImpostor.MeshImpostor:
|
|
|
return "Mesh";
|
|
|
- case BABYLON.PhysicsImpostor.CylinderImpostor:
|
|
|
+ case PhysicsImpostor.CylinderImpostor:
|
|
|
return "Cylinder";
|
|
|
- case BABYLON.PhysicsImpostor.ParticleImpostor:
|
|
|
+ case PhysicsImpostor.ParticleImpostor:
|
|
|
return "Particle";
|
|
|
- case BABYLON.PhysicsImpostor.HeightmapImpostor:
|
|
|
+ case PhysicsImpostor.HeightmapImpostor:
|
|
|
return "Heightmap";
|
|
|
}
|
|
|
|
|
@@ -175,11 +175,11 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
<FloatLineComponent lockObject={this.props.lockObject} label="Alpha index" target={mesh} propertyName="alphaIndex" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
<CheckBoxLineComponent label="Receive shadows" target={mesh} propertyName="receiveShadows" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
{
|
|
|
- mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind) &&
|
|
|
+ mesh.isVerticesDataPresent(VertexBuffer.ColorKind) &&
|
|
|
<CheckBoxLineComponent label="Use vertex colors" target={mesh} propertyName="useVertexColors" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
}
|
|
|
{
|
|
|
- scene.fogMode !== BABYLON.Scene.FOGMODE_NONE &&
|
|
|
+ scene.fogMode !== Scene.FOGMODE_NONE &&
|
|
|
<CheckBoxLineComponent label="Apply fog" target={mesh} propertyName="applyFog" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
}
|
|
|
{
|
|
@@ -193,15 +193,15 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
<CheckBoxLineComponent label="Compute bones using shaders" target={mesh} propertyName="computeBonesUsingShaders" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
}
|
|
|
<CheckBoxLineComponent label="Collisions" target={mesh} propertyName="checkCollisions" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
- <TextLineComponent label="Has normals" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="Has vertex colors" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has UV set 0" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has UV set 1" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has UV set 2" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV3Kind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has UV set 3" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV4Kind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has tangents" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.TangentKind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has matrix weights" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind) ? "Yes" : "No"} />
|
|
|
- <TextLineComponent label="has matrix indices" value={mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="Has normals" value={mesh.isVerticesDataPresent(VertexBuffer.NormalKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="Has vertex colors" value={mesh.isVerticesDataPresent(VertexBuffer.ColorKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has UV set 0" value={mesh.isVerticesDataPresent(VertexBuffer.UVKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has UV set 1" value={mesh.isVerticesDataPresent(VertexBuffer.UV2Kind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has UV set 2" value={mesh.isVerticesDataPresent(VertexBuffer.UV3Kind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has UV set 3" value={mesh.isVerticesDataPresent(VertexBuffer.UV4Kind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has tangents" value={mesh.isVerticesDataPresent(VertexBuffer.TangentKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has matrix weights" value={mesh.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) ? "Yes" : "No"} />
|
|
|
+ <TextLineComponent label="has matrix indices" value={mesh.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) ? "Yes" : "No"} />
|
|
|
</LineContainerComponent>
|
|
|
{
|
|
|
mesh.physicsImpostor != null &&
|
|
@@ -219,7 +219,7 @@ export class MeshPropertyGridComponent extends React.Component<IMeshPropertyGrid
|
|
|
<CheckBoxLineComponent label="Display normals" isSelected={() => displayNormals} onSelect={() => this.displayNormals()} />
|
|
|
}
|
|
|
{
|
|
|
- mesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind) &&
|
|
|
+ mesh.isVerticesDataPresent(VertexBuffer.NormalKind) &&
|
|
|
<CheckBoxLineComponent label="Render vertex normals" isSelected={() => renderNormalVectors} onSelect={() => this.renderNormalVectors()} />
|
|
|
}
|
|
|
<AxesViewerComponent node={mesh} />
|