SHARE
TWEET

Untitled

a guest Apr 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*jshint esversion: 6 */
  2. // @ts-check
  3.  
  4. // these four lines fake out TypeScript into thinking that THREE
  5. // has the same type as the T.js module, so things work for type checking
  6. // type inferencing figures out that THREE has the same type as T
  7. // and then I have to use T (not THREE) to avoid the "UMD Module" warning
  8. /**  @type typeof import("./THREE/threets/index"); */
  9. let T;
  10. // @ts-ignore
  11. T = THREE;
  12.  
  13. // get things we may need
  14. import { GrWorld } from "./Framework/GrWorld.js";
  15. import { GrObject } from "./Framework/GrObject.js";
  16. import * as InputHelpers from "./Libs/inputHelpers.js";
  17. import * as Helpers from "./Libs/helpers.js";
  18. class CubeObject extends GrObject {
  19.     constructor() {
  20.         let geometry = new T.Geometry();
  21.         geometry.vertices.push(new T.Vector3(1,1,0)); //0
  22.         geometry.vertices.push(new T.Vector3( 1,0, 0)); //1
  23.         geometry.vertices.push(new T.Vector3( 0,1, 0)); //2
  24.         geometry.vertices.push(new T.Vector3( 0,0,0)); //3
  25.         geometry.vertices.push(new T.Vector3( 0,1,1)); //4
  26.         geometry.vertices.push(new T.Vector3( 0,0,1)); //5
  27.         geometry.vertices.push(new T.Vector3( 1,1,1)); //6
  28.         geometry.vertices.push(new T.Vector3( 1,0,1)); //7
  29.         //
  30.         let f1 = new T.Face3(0,1,2);
  31.         geometry.faceVertexUvs = [ [] ];
  32.         geometry.faces.push(f1);
  33.         geometry.faceVertexUvs[0].push([new T.Vector2(0.333,0.333), new T.Vector2(0.333,0), new T.Vector2(0.666,0.333)]);
  34.         let f2 = new T.Face3(2,1,3);
  35.         geometry.faces.push(f2);
  36.         geometry.faceVertexUvs[0].push([new T.Vector2(0.666,0.333), new T.Vector2(0.333,0), new T.Vector2(.666,0)]);
  37.         let f3 = new T.Face3(2,3,4);
  38.         geometry.faces.push(f3);
  39.         geometry.faceVertexUvs[0].push([new T.Vector2(.666,0.333), new T.Vector2(.666,0), new T.Vector2(1,.333)]);
  40.         let f4 = new T.Face3(4,3,5);
  41.         geometry.faces.push(f4);
  42.         geometry.faceVertexUvs[0].push([new T.Vector2(1,.333), new T.Vector2(.666,0), new T.Vector2(1,0)]);
  43.         let f5 = new T.Face3(4,5,6);
  44.         geometry.faces.push(f5);
  45.         geometry.faceVertexUvs[0].push([new T.Vector2(0,0.666), new T.Vector2(0,.333), new T.Vector2(.333,.666)]);
  46.         let f6 = new T.Face3(6,5,7);
  47.         geometry.faces.push(f6);
  48.         geometry.faceVertexUvs[0].push([new T.Vector2(.333,0.666), new T.Vector2(0,.333), new T.Vector2(.333,.333)]);
  49.         let f7 = new T.Face3(6,7,0);
  50.         geometry.faces.push(f7);
  51.         geometry.faceVertexUvs[0].push([new T.Vector2(.333,.666), new T.Vector2(.333,.333), new T.Vector2(.666,.666)]);
  52.         let f8 = new T.Face3(0,7,1);
  53.         geometry.faces.push(f8);
  54.         geometry.faceVertexUvs[0].push([new T.Vector2(.666,.666), new T.Vector2(.333,.333), new T.Vector2(.666,.333)]);
  55.         let f9 = new T.Face3(0,2,6);
  56.         geometry.faces.push(f9);
  57.         geometry.faceVertexUvs[0].push([new T.Vector2(.666,.666), new T.Vector2(.666,.333), new T.Vector2(1,.666)]);
  58.         let f10 = new T.Face3(6,2,4);
  59.         geometry.faces.push(f10);
  60.         geometry.faceVertexUvs[0].push([new T.Vector2(1,0.666), new T.Vector2(.666,.333), new T.Vector2(1,.333)]);
  61.         let f11 = new T.Face3(1,7,3);
  62.         geometry.faces.push(f11);
  63.         geometry.faceVertexUvs[0].push([new T.Vector2(.333,1), new T.Vector2(.666,1), new T.Vector2(.333,.666)]);
  64.         let f12 = new T.Face3(3,7,5);
  65.         geometry.faces.push(f12);
  66.         geometry.faceVertexUvs[0].push([new T.Vector2(.333,.666), new T.Vector2(.666,1), new T.Vector2(.666,.666)]);
  67.         geometry.computeFaceNormals();
  68.         geometry.uvsNeedUpdate=true;
  69.         //
  70.         let tl1 = new T.TextureLoader().load("./Texture/brick-1.jpg");
  71.         let tl=new T.TextureLoader().load("./Texture/brick-2.jpg");
  72.         let material = new T.MeshStandardMaterial({map:tl1, roughness:0.75});
  73.         material.bumpMap = tl;
  74.         let mesh = new T.Mesh(geometry,material);
  75.  
  76.         super("Cube",mesh);
  77.     }
  78. }
  79.  
  80. function shift(grobj,x, boolRotate) {
  81.     if(boolRotate) {
  82.         grobj.objects[0].translateY(Math.sqrt(2)/2 +.3);
  83.         grobj.objects[0].rotation.x = Math.PI/2;
  84.        
  85.     }
  86.     //grobj.objects[0].rotatateZ(Math.PI/2);
  87.     //grobj.objects[0].translateY(2);
  88.     grobj.objects[0].translateX(x);
  89.     return grobj;
  90. }
  91.  
  92. function test() {
  93.     let world = new GrWorld();
  94.    
  95.     world.scene.background = new T.CubeTextureLoader()
  96.         .setPath("/Texture/SKYBOX/")
  97.         .load( [
  98.             'x-p.png',
  99.             'x-n.png',
  100.             'y-p.png',
  101.             'y-n.png',
  102.             'z-p.png',
  103.             'z-n.png'
  104.     ]);
  105.    
  106.     world.go();
  107.     let t2 = shift(new CubeObject(), 0, 0);
  108.     world.add(t2);
  109. }
  110. Helpers.onWindowOnload(test);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top