Skip to content

Commit

Permalink
prep for v4.2 release tomorrow
Browse files Browse the repository at this point in the history
  • Loading branch information
brianzinn committed Nov 10, 2020
1 parent a0eefa3 commit 40412ad
Show file tree
Hide file tree
Showing 8 changed files with 937 additions and 469 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babylonjs/core": "^4.1.0",
"@babylonjs/gui": "^4.1.0",
"@babylonjs/inspector": "^4.1.0",
"@babylonjs/loaders": "^4.1.0",
"@babylonjs/procedural-textures": "^4.1.0",
"@babylonjs/core": "^4.2.0-rc.6",
"@babylonjs/gui": "^4.2.0-rc.6",
"@babylonjs/inspector": "4.2.0-rc.6",
"@babylonjs/loaders": "4.2.0-rc.6",
"@babylonjs/procedural-textures": "4.2.0-rc.6",
"@inlet/react-pixi": "^1.2.8",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-typescript": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/customHosts/LoadedModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IParticleSystem, Skeleton, AnimationGroup, AbstractMesh, Nullable, Vector3, BoundingInfo, SceneLoaderProgressEvent } from "@babylonjs/core"
import { IParticleSystem, Skeleton, AnimationGroup, AbstractMesh, Nullable, Vector3, BoundingInfo, ISceneLoaderProgressEvent } from "@babylonjs/core"
import "@babylonjs/loaders"

export enum LoaderStatus {
Expand Down
4 changes: 2 additions & 2 deletions src/customHosts/ModelLifecycleListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Nullable,
ISceneLoaderPlugin,
ISceneLoaderPluginAsync,
SceneLoaderProgressEvent
ISceneLoaderProgressEvent
} from "@babylonjs/core"
import "@babylonjs/loaders"
import { applyUpdateToInstance } from "../UpdateInstance"
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class ModelLifecycleListener implements LifecycleListener<LoadedM
}
}
},
(event: SceneLoaderProgressEvent): void => {
(event: ISceneLoaderProgressEvent): void => {
if (this.props.onLoadProgress) {
this.props.onLoadProgress(event)
}
Expand Down
1,033 changes: 672 additions & 361 deletions src/generatedCode.ts

Large diffs are not rendered by default.

268 changes: 178 additions & 90 deletions src/generatedProps.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/model/ModelProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vector3, SceneLoaderProgressEvent, AbstractMesh } from "@babylonjs/core";
import { Vector3, ISceneLoaderProgressEvent, AbstractMesh } from "@babylonjs/core";
import { LoadedModel } from "../customHosts/LoadedModel";
import { FiberMeshPropsHandler, FiberAbstractMeshPropsHandler, FiberTransformNodePropsHandler, FiberNodePropsHandler } from "../generatedCode";
import BasePropsHandler from "../BasePropsHandler";
Expand All @@ -21,7 +21,7 @@ export type ModelProps = {
scaleToDimension?: number
onModelLoaded?: (model: LoadedModel) => void
onModelError?: (model: LoadedModel) => void
onLoadProgress?: (event: SceneLoaderProgressEvent) => void
onLoadProgress?: (event: ISceneLoaderProgressEvent) => void
onCreated?: (rootMesh: AbstractMesh) => void
}

Expand Down
69 changes: 69 additions & 0 deletions stories/babylonjs/Basic/customMeshes.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { useEffect, useState } from 'react'
import { Engine, Scene, useBabylonScene } from '../../../dist/react-babylonjs'
import { Mesh, VertexData, Vector3 } from '@babylonjs/core';
import '../../style.css'

export default { title: 'Babylon Basic' };

const CustomMesh = (props) => {
const scene = useBabylonScene();

const [customMesh] = useState(() => {
const meshInstance = new Mesh(props.name, scene);

//Set arrays for positions and indices
var positions = [-5, 2, -3, -7, -2, -3, -3, -2, -3, 5, 2, 3, 7, -2, 3, 3, -2, 3];
var indices = [0, 1, 2, 3, 4, 5];
var colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1];

//Empty array to contain calculated values
var normals = [];

var vertexData = new VertexData();
VertexData.ComputeNormals(positions, indices, normals);

//Assign positions, indices and normals to vertexData
vertexData.positions = positions;
vertexData.indices = indices;
vertexData.normals = normals;
vertexData.colors = colors;

//Apply vertexData to custom mesh
vertexData.applyToMesh(meshInstance);

return meshInstance;
})

useEffect(() => {
return () => {
customMesh.dispose();
}
}, [])

return (
<mesh fromInstance={customMesh} position={props.position}>
<standardMaterial name={`${props.name}-mat`} wireframe={props.useWireframe} />
</mesh>
)
}

export const CustomMeshes = () => (
<div style={{ flex: 1, display: 'flex' }}>
<Engine antialias adaptToDeviceRatio canvasId='babylonJS' >
<Scene>
<arcRotateCamera
name="camera1"
target={Vector3.Zero()}
alpha={Math.PI / 2}
beta={Math.PI / 2}
radius={20}
/>
<hemisphericLight name='light1' intensity={0.7} direction={Vector3.Up()} />

<CustomMesh name='custom-0' position={new Vector3(0, 0, 0)} useWireframe={false} />
<CustomMesh name='custom-2' position={new Vector3(0, 2, 0)} useWireframe={true} />
<CustomMesh name='custom-4' position={new Vector3(0, 4, 0)} useWireframe={false} />
</Scene>
</Engine>
</div>
)
16 changes: 8 additions & 8 deletions tools/generate-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ classesOfInterest.set("Light", undefined);
classesOfInterest.set("Control", undefined);
classesOfInterest.set("Control3D", undefined);
classesOfInterest.set("GUI3DManager", undefined);
classesOfInterest.set("BaseTexture", undefined);
classesOfInterest.set("ThinTexture", undefined);
classesOfInterest.set("AdvancedDynamicTexture", undefined);
classesOfInterest.set("ShadowGenerator", undefined)
classesOfInterest.set("CascadedShadowGenerator", undefined)
Expand Down Expand Up @@ -931,7 +931,7 @@ const addPropsAndHandlerClasses = (generatedCodeSourceFile: SourceFile, generate
let addedProperties = new Set<string>();

// These properties break out to specific method handlers
type PropertyKind = 'BabylonjsCoreBaseTexture' | 'BabylonjsCoreColor3' | 'BabylonjsCoreColor4' | 'BabylonjsCoreVector3' | 'BabylonjsCoreFresnelParameters' | 'BabylonjsCoreQuaternion' |
type PropertyKind = 'BabylonjsCoreThinTexture' | 'BabylonjsCoreColor3' | 'BabylonjsCoreColor4' | 'BabylonjsCoreVector3' | 'BabylonjsCoreFresnelParameters' | 'BabylonjsCoreQuaternion' |
'BabylonjsGuiControl' | 'number[]' | 'lambda' | 'observable' | 'method' | 'primitive' | 'object';
type NameAndType = {
name: string
Expand Down Expand Up @@ -1000,7 +1000,7 @@ const addPropsAndHandlerClasses = (generatedCodeSourceFile: SourceFile, generate
})
} else {
switch (type) {
case 'BabylonjsCoreBaseTexture':
case 'BabylonjsCoreThinTexture':
case 'BabylonjsCoreColor3':
case 'BabylonjsCoreColor4': // Color4.equals() not added until PR #5517
case 'BabylonjsCoreVector3':
Expand Down Expand Up @@ -1114,7 +1114,7 @@ const addPropsAndHandlerClasses = (generatedCodeSourceFile: SourceFile, generate
case 'BabylonjsCoreFresnelParameters':
writer.writeLine(`checkFresnelParametersDiff(oldProps.${propToCheck.name}, newProps.${propToCheck.name}, '${propToCheck.name}', changedProps)`);
break;
case 'BabylonjsCoreBaseTexture':
case 'BabylonjsCoreThinTexture':
writer.writeLine(`checkTextureDiff(oldProps.${propToCheck.name}, newProps.${propToCheck.name}, '${propToCheck.name}', changedProps)`)
break;
case 'observable':
Expand Down Expand Up @@ -1333,7 +1333,7 @@ const createClassesInheritedFrom = (generatedCodeSourceFile: SourceFile, generat
const newClassDeclaration = createClassDeclaration(derivedClassDeclaration, baseClassDeclaration, generatedCodeSourceFile, generatedPropsSourceFile, extra);
addCreateInfoFromConstructor(derivedClassDeclaration, newClassDeclaration, classNamespaceTuple.moduleDeclaration, generatedCodeSourceFile, generatedPropsSourceFile);

// AdvancedDynamicTexture has different metadata than other BaseTexture derived classes.
// AdvancedDynamicTexture has different metadata than other ThinTexture derived classes.
const metadata: InstanceMetadataParameter | undefined = metadataFromClassName ? metadataFromClassName(newClassDeclaration.getName()!) : undefined;

addMetadata(newClassDeclaration, derivedClassDeclaration, metadata);
Expand Down Expand Up @@ -1579,7 +1579,7 @@ const generateCode = async () => {
createClassesInheritedFrom(generatedCodeSourceFile, generatedPropsSourceFile, classesOfInterest.get("EffectLayer")!, () => ({ isEffectLayer: true }));
}

if (classesOfInterest.get("BaseTexture")) {
if (classesOfInterest.get("ThinTexture")) {
const fromClassName = (className: string): InstanceMetadataParameter => {
if (className === `${ClassNamesPrefix}AdvancedDynamicTexture`) {
return {
Expand Down Expand Up @@ -1607,7 +1607,7 @@ const generateCode = async () => {
}
};

createClassesInheritedFrom(generatedCodeSourceFile, generatedPropsSourceFile, classesOfInterest.get("BaseTexture")!, fromClassName, onTexturesCreate);
createClassesInheritedFrom(generatedCodeSourceFile, generatedPropsSourceFile, classesOfInterest.get("ThinTexture")!, fromClassName, onTexturesCreate);
}

createSingleClass("GUI3DManager", generatedCodeSourceFile, generatedPropsSourceFile, undefined, { isGUI3DControl: true }, () => { return; });
Expand Down Expand Up @@ -1737,4 +1737,4 @@ result.then(() => {
console.log('completed without errors');
}).catch(reason => {
console.error('failed:', reason);
})
})

0 comments on commit 40412ad

Please sign in to comment.