예제 #1
0
        public THREE_OBJAsset(IHTMLImage i, string uri)
        {
            new Action(
                async delegate
            {
                await i;

                var texture = new THREE.Texture(
                    //new HTML.Images.FromAssets.ash_uvgrid01()
                    //new HTML.Images.FromAssets.texture_palm()
                    i
                    );
                texture.needsUpdate = true;

                // model


                var loader = new THREE.OBJLoader();
                loader.load(
                    //'obj/male02/male02.obj',
                    //"assets/WebGLOBJExperiment/male02.obj",
                    //"assets/WebGLOBJExperiment/palm.obj",
                    uri,

                    new Action <THREE.Object3D>(
                        o =>
                {
                    o.traverse(
                        new Action <object>(
                            child =>
                    {
                        var m = child as THREE.Mesh;
                        if (m != null)
                        {
                            m.material.map = texture;

                            // http://stackoverflow.com/questions/10857233/in-three-js-alpha-channel-works-inconsistently
                            (m.material as dynamic).transparent = true;
                        }
                    }
                            )
                        );



                    this.Source.SetResult(o);
                }
                        )
                    //, null, null
                    );

                //
                //await s.Task;
            }
                )();
        }
예제 #2
0
        public THREE_OBJAsset(IHTMLImage i, string uri)
        {
            new Action(
                async delegate
                {

                    await i;

                    var texture = new THREE.Texture(
                         //new HTML.Images.FromAssets.ash_uvgrid01()
                         //new HTML.Images.FromAssets.texture_palm()
                         i
                    );
                    texture.needsUpdate = true;

                    // model


                    var loader = new THREE.OBJLoader();
                    loader.load(
                        //'obj/male02/male02.obj', 
                        //"assets/WebGLOBJExperiment/male02.obj",
                        //"assets/WebGLOBJExperiment/palm.obj",
                        uri,

                        new Action<THREE.Object3D>(
                            o =>
                            {

                                o.traverse(
                                    new Action<object>(
                                        child =>
                                        {
                                            var m = child as THREE.Mesh;
                                            if (m != null)
                                            {

                                                m.material.map = texture;

                                                // http://stackoverflow.com/questions/10857233/in-three-js-alpha-channel-works-inconsistently
                                                (m.material as dynamic).transparent = true;

                                            }

                                        }
                                    )
                                 );




                                this.Source.SetResult(o);
                            }
                        )
                    //, null, null
                    );

                    //
                    //await s.Task;
                }
            )();

        }