Jump to content

[SOLVED] - Dear Dave, Need Your Help


MackeyK24
 Share

Recommended Posts

Very Kool :)

 

            // Heightmap
            var floatView = new Float32Array(options.buffer.buffer);

            // Vertices
            for (row = 0; row <= options.subdivisions; row++) {
                for (col = 0; col <= options.subdivisions; col++) {
                    var position = new Vector3((col * options.width) / options.subdivisions - (options.width / 2.0), 0, ((options.subdivisions - row) * options.height) / options.subdivisions - (options.height / 2.0));

                    // Compute height
                    var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
                    var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;

                    // Unpack height
                    var pos = (heightMapX + heightMapY * options.bufferWidth);
                    var gradient = floatView[pos];

                    position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;

                    // Add  vertex
                    positions.push(position.x, position.y, position.z);
                    normals.push(0, 0, 0);
                    uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
                }
            }

 

 Working Great... You da man @Sebavan:)

 

Link to comment
Share on other sites

Looks good... Now I'm only using VERY LOW POLY now... not trying to make a smooth version like when we first started at the creategroundfromheightmap was the ONLY mesh for the terrain... Now we use Detail mesh/Collision Mesh combo and the collision mesh is made from the new (thanks to @Sebavan) BABYLON.SceneManager.createGroundTerrain() function in BJS unity toolkit. And it only using 50 to 100 subdivisions so it will yield MUCH LOWER POLYS for the terrain collision mesh... SO IT WILL BE BLOCKY... Buts that ok... its just there for collision now anyways... and you can control how DETAILED you want your invisible collision mesh to be with the "Ground Tessellation" option on the Babylon Terrain Generator Component :)

Dude... Thanks again for ALL YOU HELP :)

 

Link to comment
Share on other sites

Ready to post first part of my api (babylon.unity.ts)

But I don't really know all the ins and outs of the github/gulp build process...

I would like to simply in github/master/src/unity/babylon.unity.ts

that "SOMEHOW" ends up in /dist/preview release/unity/babylon.unity.js and babylon.unity.d.ts  

@Deltakosh or @Sebavan can i just send either on of you guys the babylon.unity.ts file and you put where it should go(not sure about how it gets built every night) ... I can then take it from there

Link to comment
Share on other sites

@Sebavan What about the master/src/tools folder... then we can treat the unity toolkit api just like gamepad or virtual joystick ... Just another tool (and also i think it would end up in main babylon.js)... Note: All my runtime components api stuff will actually work WITH or WITHOUT unity created scenes. Remember the unity toolkit REALLY just adds metadata to the scene file... Technically that metadata can get created with anything, even by hand or using other tools. The only real check i do is the loader checkers for node.metadata.unity... If i change that to node.metadata.api or something like that... You could really use my whole scene manager/component from just strait code (WITH OR WITHOUT UNITY)...and use SceneManager.addSceneComponent(mesh, "Project.MyComponent") at runtime.

Let me know what you think :)

@Deltakosh

 

Link to comment
Share on other sites

If it is not tied to Unity, do not call it Unity and makes sense to have in the core dist depending on the added value for everybody.

For the unity only related part I would add it in the loaders folder like we already have obj, we could have a custom unity loader for the specific.

With both approach you only need to reference your new ts files in the tools/gulp/config.json and that is it, all the rest will be automated.

I f you submit the PR, we (I mean @Deltakosh mostly) can probe for the re usability and worst case you ll have to move a bit or rename.

 

Link to comment
Share on other sites

@Sebavan and @Deltakosh I like the tools approach.... I will go thru the API (Removing all specific UNITY references and gear the API for more of a Scene Manager And Scene Component API that knows nothing about unity)

I will then just pull the UnityFileLoader part into a separate small file and use just like STL and OBJ file loader.

Then everybody can choose to use Scene Component API approach or NOT... And also have the option of using Unity to put your scene file together or NOT 

We can then go from there :)

 

Link to comment
Share on other sites

Having Problem Submitting PR... I am trying to commit the same files i been using the whole time to compile my scene manager api (on my client pc)

but when i submit to github its get all kind of syntax errors that should be:

[09:58:21] Using gulpfile ~/build/BabylonJS/Babylon.js/Tools/Gulp/gulpfile.js
[09:58:21] Starting 'typescript-compile'...
[09:58:31] Finished 'typescript-compile' after 10 s
[09:58:32] Using gulpfile ~/build/BabylonJS/Babylon.js/Tools/Gulp/gulpfile.js
[09:58:32] Starting 'canvas2D'...
[09:58:32] Starting 'materialsLibrary'...
[09:58:33] Starting 'postProcessesLibrary'...
[09:58:33] Starting 'proceduralTexturesLibrary'...
[09:58:33] Starting 'loaders'...
[09:58:33] Starting 'serializers'...
[09:58:33] Starting 'inspector'...
[09:58:33] Starting 'sceneManager'...
../../sceneManager/src/babylon.scenecomponents.ts(4,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(4,31): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(4,40): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(5,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(5,30): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(5,39): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(16,26): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(16,32): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(16,41): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(16,55): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(16,88): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(110,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(110,31): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(110,40): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(118,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(118,30): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(118,39): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(126,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(126,29): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(126,37): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenecomponents.ts(171,26): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenecomponents.ts(171,34): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenemanager.ts(38,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenemanager.ts(38,27): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenemanager.ts(39,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenemanager.ts(39,28): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenemanager.ts(40,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenemanager.ts(40,33): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenenavagent.ts(17,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenenavagent.ts(17,29): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenenavagent.ts(17,37): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenenavagent.ts(18,25): error TS1005: '=' expected.
../../sceneManager/src/babylon.scenenavagent.ts(18,29): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenenavagent.ts(18,37): error TS1005: ';' expected.
../../sceneManager/src/babylon.scenemanager.ts(4,42): error TS4070: Parameter 'scene' of public static method from exported class has or is using private name 'Scene'.
../../sceneManager/src/babylon.scenemanager.ts(8,57): error TS4070: Parameter 'engine' of public static method from exported class has or is using private name 'Engine'.
../../sceneManager/src/babylon.scenemanager.ts(14,81): error TS4070: Parameter 'engine' of public static method from exported class has or is using private name 'Engine'.
../../sceneManager/src/babylon.scenemanager.ts(14,109): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'Scene'.
../../sceneManager/src/babylon.scenemanager.ts(14,167): error TS4070: Parameter 'onerror' of public static method from exported class has or is using private name 'Scene'.
../../sceneManager/src/babylon.scenemanager.ts(22,99): error TS4070: Parameter 'scene' of public static method from exported class has or is using private name 'Scene'.
../../sceneManager/src/babylon.scenemanager.ts(22,127): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'AbstractMesh'.
../../sceneManager/src/babylon.scenemanager.ts(22,160): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'ParticleSystem'.
../../sceneManager/src/babylon.scenemanager.ts(22,189): error TS4070: Parameter 'onsuccess' of public static method from exported class has or is using private name 'Skeleton'.
../../sceneManager/src/babylon.scenemanager.ts(22,259): error TS4070: Parameter 'onerror' of public static method from exported class has or is using private name 'Scene'.
../../sceneManager/src/babylon.scenemanager.ts(786,45): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'.
../../sceneManager/src/babylon.scenemanager.ts(794,45): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'.
../../sceneManager/src/babylon.scenemanager.ts(799,46): error TS4073: Parameter 'camera' of public method from exported class has or is using private name 'FreeCamera'.
[09:59:01] TypeScript: 34 syntax errors
[09:59:01] TypeScript: 13 emit errors
[09:59:01] TypeScript: emit failed
[09:59:01] Finished 'serializers' after 29 s

 

Since this is my first real commit... I don't know what the deal is here :(

 

Link to comment
Share on other sites

Why can't typescript in babylon js main project have public static function defined like the following (which compiles fine on my machine):

    export class SceneManager {
        public static GetInstance(scene: BABYLON.Scene): BABYLON.SceneManager {
            return ((<any>scene).manager) ? (<any>scene).manager as BABYLON.SceneManager : null;
        }

        public static CreateScene(name: string, engine: BABYLON.Engine): BABYLON.Scene {
            var result: BABYLON.Scene = new BABYLON.Scene(engine);
            BABYLON.SceneManager.parseSceneMetadata("/", name, result);
            return result;
        }

        public static LoadScene(rootUrl: string, sceneFilename: string, engine: BABYLON.Engine, onsuccess?: (scene: BABYLON.Scene) => void, progressCallBack?: any, onerror?: (scene: BABYLON.Scene) => void): void {
            var onparse = (scene: BABYLON.Scene) => {
                BABYLON.SceneManager.parseSceneMetadata(rootUrl, sceneFilename, scene);
                if (onsuccess) onsuccess(scene);
            };
            BABYLON.SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onparse, progressCallBack, onerror);
        }

        public static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: BABYLON.Scene, onsuccess?: (meshes: BABYLON.AbstractMesh[], particleSystems: BABYLON.ParticleSystem[], skeletons: BABYLON.Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: BABYLON.Scene, message: string, exception?: any) => void): void {
            var onparse = (meshes: BABYLON.AbstractMesh[], particleSystems: BABYLON.ParticleSystem[], skeletons: BABYLON.Skeleton[]) => {
                BABYLON.SceneManager.parseMeshMetadata(meshes, scene);
                if (onsuccess) onsuccess(meshes, particleSystems, skeletons);
            };
            BABYLON.SceneLoader.ImportMesh(meshesNames, rootUrl, sceneFilename, scene, onparse, progressCallBack, onerror);
        }

        public static RegisterLoader(handler: (root: string, name: string) => void): void {
            BABYLON.SceneManager.loader = handler;
        }
}

 

 

It does not seem to like the following format:

 

module BABYLON {

    export class SceneManager {

        public static GetInstance(scene: BABYLON.Scene): BABYLON.SceneManager {}

    }

}

Should be able to use as: BABYLON.SceneManagerGetInstance() but the PR submit that this has syntax errors... What kind of syntax does it want???

That seems perfectly fine type script function to me :(

 

Link to comment
Share on other sites

Hey @Deltakosh I cleaned up and made the first PR.

This is the new PURE BabylonJS Managed Scene Component API. Can now use all the Scene Manager And Scene Component API from runtime using just code and NO UNITY

There will be the actual 'U3D - BabylonJS Toolkit' which i will put in exporters/unity3d... That new toolkit will use the new pure BabylonJS Scene Manager on the preview index page... Other than that the Unity Exporter is now JUST A GAME IDE... All the Managed Scene Component API is now pure BabylonJS :)

 

Link to comment
Share on other sites

Yo @adam ... Thanks man... That was it ... DOES NOT LIKE 'readonly'

Turns out i am using Typescript 2.0.10 compiler on my machine which works great... I think BabylonJS is still compiling with typescript 1.7

Anyways... I made all readonly use 'private _myvar' backing fields and then

public get myvar():any {

  return this._myvar;

}

Works great now... Thanks for the info :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...