コード例 #1
0
        public BoxConstrain(THREE.Vector3 center, double w, double h, double d)
        {
            Center = center;
            Width=w;
            Height=h;
            Depth=d;

            MakeBox();
            MakeMesh();
        }
コード例 #2
0
        public override THREE.Vector3 Constrain(THREE.Vector3 pos)
        {
            THREE.Vector3 diff = DivVector.sub(pos, Center).clone();
            if (diff.length() < Radius)
            {
                double dist = Radius - diff.length();

                diff.normalize().multiplyScalar(dist);
                return diff;
            }
            return null;
        }
コード例 #3
0
        public override THREE.Vector3 Constrain(THREE.Vector3 pos)
        {
            if (box.containsPoint(pos))
            {
                double minDist = double.MaxValue;
                double dist = 0;
                int dir = 0;

                for (int i = 0; i < 6; i++)
                {
                    if (IsX(i))
                    {
                        dist = Distance(pos.x, i);
                        if (Math.Abs(dist) < Math.Abs(minDist) && dist < 0)
                        {
                            minDist = dist;
                            dir = i;
                        }
                    }
                    else if (IsY(i))
                    {
                        dist = -Distance(pos.y, i);
                        if (Math.Abs(dist) < Math.Abs(minDist) && dist < 0)
                        {
                            minDist = dist;
                            dir = i;
                        }
                    }
                    else if(IsZ(i))
                    {
                        dist = Distance(pos.z, i);
                        if (Math.Abs(dist) < Math.Abs(minDist) && dist < 0)
                        {
                            minDist = dist;
                            dir = i;
                        }
                    }
                }

                THREE.Vector3 d = Dirs[dir].clone().multiplyScalar(minDist*1.3);

                return d;

            }
            return null;
        }
コード例 #4
0
        private void MakeClothMesh(THREE.Texture t)
        {
            THREE.Texture clothTexture = t;

            clothTexture.wrapS = THREE.WrapType.MirroredRepeatWrapping;
            clothTexture.wrapT = THREE.WrapType.RepeatWrapping;

            clothTexture.repeat.y = -1;
            clothTexture.anisotropy = 16;

            THREE.MeshPhongMaterial clothMaterial = new THREE.MeshPhongMaterial();

            clothMaterial.specular = new THREE.Color().setHex(0x030303);
            //clothMaterial.color = new THREE.Color(1, 0.4, 0);
            clothMaterial.map = clothTexture;
            clothMaterial.side = THREE.SideType.DoubleSide;
            clothMaterial.alphaTest = 0.5;
            clothMaterial.wireframe = false;
            clothMaterial.wireframeLinewidth= 2;

            // cloth mesh
            THREE.Mesh clothMesh = new THREE.Mesh(cloth.Geometry, clothMaterial);
            clothMesh.position.set(0, 0, 0);
            clothMesh.castShadow = true;

            THREE.ShaderMaterial shaderMat = null; ;

            THREE.ShaderMaterialOptions o = new THREE.ShaderMaterialOptions()
            {
                texture = new THREE.Uniform() { type = "t", value = clothTexture }
            };

            shaderMat = new THREE.ShaderMaterial();

            shaderMat.side = THREE.SideType.DoubleSide;

            string vertexShader = Shaders.vertex;
            string fragmentShader = Shaders.fragment;
            shaderMat.vertexShader = vertexShader;
            shaderMat.fragmentShader = fragmentShader;

            clothMesh.customDepthMaterial = shaderMat;
            scene.add(clothMesh);
        }
コード例 #5
0
    public void OnClick()
    {
        hasBought           = true;
        button.interactable = false;
        text.fontSize       = 40;
        text.text           = "HIRED!";
        text.color          = new Color(1f, 0.2f, 0.2f);

        Money.money -= buyPrice;

        switch (targetModuleNumber)
        {
        case 1:
            ONE.ManagerPurchase();
            break;

        case 2:
            TWO.ManagerPurchase();
            break;

        case 3:
            THREE.ManagerPurchase();
            break;

        case 4:
            FOUR.ManagerPurchase();
            break;

        case 5:
            break;

        case 6:
            break;

        case 7:
            break;

        case 8:
            break;
        }

        SaveSystem.SaveAll();
    }
コード例 #6
0
 public static THREE.Vector3 sub(THREE.Vector3 v1, THREE.Vector3 v2)
 {
     diff.subVectors(v1, v2);
     return diff;
 }
コード例 #7
0
 public void addForce(THREE.Vector3 force)
 {
     THREE.Vector3 a = force.clone();
     a.multiplyScalar(invMass);
     acc.add(a);
 }
コード例 #8
0
        public Particle(double m, THREE.Vector3 pos)
        {
            position = pos.clone();
            previous = pos.clone();
            original = pos.clone();

            acc = new THREE.Vector3(0, 0, 0);

            mass = m;
            invMass = 1.0 / mass;
        }
コード例 #9
0
 public BallConstrain(THREE.Vector3 c, double ballRadius)
 {
     Center = c;
     Radius = ballRadius;
     MakeMesh();
 }
コード例 #10
0
 /// <summary>
 /// return a forced displacement constrain (delta)
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public abstract THREE.Vector3 Constrain(THREE.Vector3 pos);
コード例 #11
0
 public static Texture loadTexture(string p1, THREE.MappingMode m, Action action)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
 public static Texture loadTexture(string p1,THREE.MappingMode m, object render)
 {
     return null;
 }
コード例 #13
0
        // var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
        static THREE.Vector3[] hilbert3D(
            THREE.Vector3 center,
            double size = 25.0,
            int iterations = 1,
            int v0 = 0,
            int v1 = 1,
            int v2 = 2,
            int v3 = 3,
            int v4 = 4,
            int v5 = 5,
            int v6 = 6,
            int v7 = 7)
        {
            // 0:71ms {{ i = 0, x = -18.75, y = 18.75, z = -18.75 }}

            // Default Vars
            var half = size / 2;


            var vec_s = new[] {
                new THREE.Vector3(center.x - half, center.y + half, center.z - half),
                new THREE.Vector3(center.x - half, center.y + half, center.z + half),
                new THREE.Vector3(center.x - half, center.y - half, center.z + half),
                new THREE.Vector3(center.x - half, center.y - half, center.z - half),
                new THREE.Vector3(center.x + half, center.y - half, center.z - half),
                new THREE.Vector3(center.x + half, center.y - half, center.z + half),
                new THREE.Vector3(center.x + half, center.y + half, center.z + half),
                new THREE.Vector3(center.x + half, center.y + half, center.z - half)
            };

            var vec = new[] {
                vec_s[v0],
                vec_s[v1],
                vec_s[v2],
                vec_s[v3],
                vec_s[v4],
                vec_s[v5],
                vec_s[v6],
                vec_s[v7]
            };

            // Recurse iterations

            //if (--iterations >= 0)
            if (iterations > 0)
            {
                iterations--;

                var tmp = new[] {
                    hilbert3D(vec[0], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1),
                    hilbert3D(vec[1], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3),
                    hilbert3D(vec[2], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3),
                    hilbert3D(vec[3], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5),
                    hilbert3D(vec[4], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5),
                    hilbert3D(vec[5], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7),
                    hilbert3D(vec[6], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7),
                    hilbert3D(vec[7], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7)
                };

                // Return recursive call
                return tmp.SelectMany(x => x).ToArray();
            }

            // Return complete Hilbert Curve.
            return vec;
        }
コード例 #14
0
 /// <summary>
 /// Abstract method to get intersections between a casted ray and this object. 
 /// Subclasses such as Mesh, Line, and Points implement this method in order to participate in raycasting.
 /// </summary>
 /// <param name="?"></param>
 /// <param name="?"></param>
 public void raycast(THREE.Raycaster r, object intersects)
 {
 }
コード例 #15
0
        private THREE.Mesh MakeMesh(THREE.BoxGeometry geometry)
        {
            THREE.Material mat = null;

            mat = new THREE.MeshLambertMaterial();
            mat.color = new THREE.Color();
            mat.color.setHex( Math.Random() * 0xffffff);

            THREE.Mesh mesh = new THREE.Mesh(geometry, mat);

            mesh.position.x = Math.Random() * 1000 - 500;
            mesh.position.y = Math.Random() * 600 - 300;
            mesh.position.z = Math.Random() * 800 - 400;

            mesh.rotation.x = Math.Random() * 2 * Math.PI;
            mesh.rotation.y = Math.Random() * 2 * Math.PI;
            mesh.rotation.z = Math.Random() * 2 * Math.PI;

            mesh.scale.x = Math.Random() * 2 + 1;
            mesh.scale.y = Math.Random() * 2 + 1;
            mesh.scale.z = Math.Random() * 2 + 1;

            mesh.castShadow = true;
            mesh.receiveShadow = true;
            return mesh;
        }
コード例 #16
0
        public void addLocation(double lat, double lon, double radius, double heigth, THREE.Object3D parent, double segments)
        {
            var phi = (lat) * Math.PI / 180;
            var theta = (lon - 180) * Math.PI / 180;
            var x = -(radius + heigth) * Math.Cos(phi) * Math.Cos(theta);
            var y = (radius + heigth) * Math.Sin(phi);
            var z = (radius + heigth) * Math.Cos(phi) * Math.Sin(theta);
            var latLongOnSphere = new THREE.Vector3(x, y, z);

            var p = new THREE.Mesh(
                    new THREE.SphereGeometry(
                        0.005,
                        (int)segments, (int)segments),
                    new THREE.MeshBasicMaterial(
                        new
                        {
                            color = "red"
                        })
                );

            p.position = latLongOnSphere;
            parent.add(p);
        }
コード例 #17
0
        private void MakeGroundPlane(THREE.Texture t)
        {
            THREE.Texture groundTexture = t;
            groundTexture.wrapS = THREE.WrapType.RepeatWrapping;
            groundTexture.wrapT = THREE.WrapType.RepeatWrapping;
            groundTexture.repeat.set(25, 25);
            groundTexture.anisotropy = 16;

            var groundMaterial = new THREE.MeshPhongMaterial();
            groundMaterial.color = new THREE.Color().setHex(0xffffff);
            groundMaterial.specular = new THREE.Color().setHex(0x111111);
            groundMaterial.map = groundTexture; ;

            THREE.Mesh planeMesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(20000, 20000), groundMaterial);
            planeMesh.position.y = -250;
            planeMesh.rotation.x = -Math.PI / 2;
            planeMesh.receiveShadow = true;
            scene.add(planeMesh);
        }