Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into…
Browse files Browse the repository at this point in the history
… nativeCanvasImage
  • Loading branch information
CedricGuillemetMS committed Jul 21, 2021
2 parents c7bd753 + 4b433e2 commit be094ca
Show file tree
Hide file tree
Showing 198 changed files with 6,668 additions and 2,610 deletions.
58 changes: 26 additions & 32 deletions Playground/libs/babylon.manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,20 @@ declare module BABYLON {
static PauseRenderLoop: boolean;
/** Set the preload auto update progress flag */
static AutoUpdateProgress: boolean;
/** Is content running in a frame window */
static IsFrameWindow(): boolean;
/** Gets the running status of the default audio context */
static HasAudioContext(): boolean;
/** Returns a Promise that resolves after the specfied time */
static WaitForSeconds: (seconds: number) => Promise<void>;
/** Post a safe message to top parent window */
static PostWindowMessage(msg: any, targetOrigin: string, transfer?: Transferable[]): void;
/** Register handler that is triggered when then engine has been resized (engine.html) */
static OnEngineResizeObservable: Observable<Engine>;
/** Register handler that is triggered when the scene has been loaded (engine.html) */
static OnLoadCompleteObservable: Observable<Engine>;
/** Registers an handler for window state show scene loader function (engine.html) */
static RegisterOnShowSceneLoader(func: (show: boolean) => void): void;
/** Registers an handler for window socket disconnect event (engine.html) */
static RegisterOnUpdateSceneLoader(func: (status: string, details: string, state: number) => void): void;
/** Registers an handler for window state show scene loader function (engine.html) */
static RegisterOnTickSceneLoader(func: (percent: number) => void): void;
/** Loads a babylon scene file using the page loader window hooks (engine.html) */
/** Loads a babylon gltf scene file (engine.html) */
static LoadSceneFile(sceneFile: string, queryString?: string): void;
/** Shows the top page scene loader (engine.html) */
static ShowParentLoader(show: boolean, duration?: number): void;
/** Get the system render quality local storage setting. */
static GetRenderQuality(): BABYLON.RenderQuality;
/** Set the system render quality local storage setting. */
static SetRenderQuality(quality: BABYLON.RenderQuality): void;
/** Get the system virtual reality local storage setting. */
static GetVirtualRealityEnabled(): boolean;
/** Set the system virtual reality local storage setting. */
static SetVirtualRealityEnabled(enabled: boolean): void;
/** Get an item from top window local storage. */
static GetLocalStorageItem(key: string): string;
/** Set an item to top window local storage. */
static SetLocalStorageItem(key: string, value: string): void;
/** Get an item from top window session storage. */
static GetSessionStorageItem(key: string): string;
/** Set an item to top window session storage. */
static SetSessionStorageItem(key: string, value: string): void;
/** Store data object in the window state cache */
static SetWindowState(name: string, data: any): void;
/** Retrieve data object from the window state cache */
static GetWindowState<T>(name: string): T;
/** Post a safe message to top or local window */
static PostWindowMessage(msg: any, targetOrigin: string, transfer?: Transferable[]): void;
private static SceneParsingEnabled;
/** Enable scene loader parsing plugin */
static EnableSceneParsing(enabled: boolean): void;
Expand All @@ -68,6 +42,18 @@ declare module BABYLON {
static GetAmbientSkybox(scene: BABYLON.Scene): BABYLON.AbstractMesh;
/** Get the scene default intenisty factor */
static GetIntensityFactor(): number;
/** Get the system render quality local storage setting. */
static GetRenderQuality(): BABYLON.RenderQuality;
/** Set the system render quality local storage setting. */
static SetRenderQuality(quality: BABYLON.RenderQuality): void;
/** Get the system virtual reality local storage setting. */
static GetVirtualRealityEnabled(): boolean;
/** Set the system virtual reality local storage setting. */
static SetVirtualRealityEnabled(enabled: boolean): void;
/** Store data object of function on the local window state. */
static SetWindowState(name: string, data: any): void;
/** Retrieve data object or function from the local window state. */
static GetWindowState<T>(name: string): T;
/** Are scene manager debugging services available. */
static IsDebugMode(): boolean;
/** Send log data directly to the console. */
Expand Down Expand Up @@ -1101,8 +1087,8 @@ declare module BABYLON {
static PointerWheelDeadZone: number;
static PointerMouseDeadZone: number;
static PointerMouseInverted: boolean;
static UseArrowKeyRotation: boolean;
static UseCanvasElement: boolean;
static UseArrowKeyRotation: boolean;
}
/**
* Unity Export Interfaces
Expand Down Expand Up @@ -1410,6 +1396,14 @@ declare module BABYLON {
static ProjectVectorOnPlane(vector: BABYLON.Vector3, planenormal: BABYLON.Vector3): BABYLON.Vector3;
/** Projects a vector onto a plane defined by a normal orthogonal to the plane and sets result */
static ProjectVectorOnPlaneToRef(vector: BABYLON.Vector3, planenormal: BABYLON.Vector3, result: BABYLON.Vector3): void;
/** Get an item from window local storage. */
static GetLocalStorageItem(key: string): string;
/** Set an item to window local storage. */
static SetLocalStorageItem(key: string, value: string): void;
/** Get an item from window session storage. */
static GetSessionStorageItem(key: string): string;
/** Set an item to window session storage. */
static SetSessionStorageItem(key: string, value: string): void;
/** TODO */
static DownloadEnvironment(cubemap: BABYLON.CubeTexture, success?: () => void, failure?: () => void): void;
static HasOwnProperty(object: any, property: string): boolean;
Expand Down
16 changes: 8 additions & 8 deletions Playground/libs/babylon.manager.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Playground/src/components/rendererComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
}

// Check for Ammo.js
let ammoInit = "";
if (code.indexOf("AmmoJSPlugin") > -1 && typeof Ammo === "function") {
await Ammo();
ammoInit = "await Ammo();";
}

// Check for Unity Toolkit
Expand Down Expand Up @@ -227,7 +228,8 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
// using the appropriate default or user-provided functions.
// (Use "window.x = foo" to allow later deletion, see above.)
code += `
window.initFunction = async function() {
window.initFunction = async function() {
${ammoInit}
var asyncEngineCreation = async function() {
try {
return ${createEngineFunction}();
Expand Down Expand Up @@ -351,6 +353,7 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
});
}
} catch (err) {
console.error(err);
this.props.globalState.onErrorObservable.notifyObservers(this._tmpErrorEvent || err);
}
}
Expand Down
46 changes: 46 additions & 0 deletions Playground/workers/navMeshWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
importScripts("https://preview.babylonjs.com/recast.js");

onmessage = function(messageEvent) {
// get message datas
const meshData = messageEvent.data;
const positions = meshData[0];
const offset = meshData[1];
const indices = meshData[2];
const indicesLength = meshData[3];
const parameters = meshData[4];

// initialize Recast
var recast = Recast();

// build rc config from parameters
const rc = new recast.rcConfig();
rc.cs = parameters.cs;
rc.ch = parameters.ch;
rc.borderSize = parameters.borderSize ? parameters.borderSize : 0;
rc.tileSize = parameters.tileSize ? parameters.tileSize : 0;
rc.walkableSlopeAngle = parameters.walkableSlopeAngle;
rc.walkableHeight = parameters.walkableHeight;
rc.walkableClimb = parameters.walkableClimb;
rc.walkableRadius = parameters.walkableRadius;
rc.maxEdgeLen = parameters.maxEdgeLen;
rc.maxSimplificationError = parameters.maxSimplificationError;
rc.minRegionArea = parameters.minRegionArea;
rc.mergeRegionArea = parameters.mergeRegionArea;
rc.maxVertsPerPoly = parameters.maxVertsPerPoly;
rc.detailSampleDist = parameters.detailSampleDist;
rc.detailSampleMaxError = parameters.detailSampleMaxError;

// create navmesh and build it from message datas
const navMesh = new recast.NavMesh();
navMesh.build(positions, offset, indices, indicesLength, rc);

// get recast uint8array
const navmeshData = navMesh.getNavmeshData();
const arrView = new Uint8Array(recast.HEAPU8.buffer, navmeshData.dataPointer, navmeshData.size);
const ret = new Uint8Array(navmeshData.size);
ret.set(arrView);
navMesh.freeNavmeshData(navmeshData);

// job done, returns the result
postMessage(ret);
}
Loading

0 comments on commit be094ca

Please sign in to comment.