-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
170 additions
and
48 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Renderer from "../lib/Renderer"; | ||
import PreLoader from "../lib/PreLoader"; | ||
import Drawing from "./Drawing"; | ||
|
||
export default class DrawingLoader extends Drawing{ | ||
|
||
|
||
constructor(renderer:Renderer,preLoader:PreLoader,url) { | ||
|
||
super(renderer,url,0) | ||
|
||
|
||
preLoader.startLoad(); | ||
this.loadURL(url).then(() => { | ||
preLoader.stopLoad(); | ||
}); | ||
|
||
|
||
} | ||
async loadURL(url: any) { | ||
|
||
const responseBuffer = await fetch(url ) | ||
|
||
let dataBuffer = await responseBuffer.arrayBuffer(); | ||
let data = new Int16Array(dataBuffer) | ||
|
||
|
||
this.offset.x =data[0] /1000; | ||
this.offset.y =data[1] /1000; | ||
this.offset.z =data[2] /1000; | ||
|
||
this.color.x =data[3] /255; | ||
this.color.y =data[4] /255; | ||
this.color.z =data[5] /255; | ||
this.material.uniforms.setUniform("color",this.color) | ||
|
||
let size = (data.length-6)/3; | ||
|
||
let bufferData =new Float32Array(size*4) | ||
let inputPos =6; | ||
let outputPos=0; | ||
for (let i= 0;i<size;i++ ){ | ||
|
||
bufferData[outputPos++] =data[inputPos++]/1000; | ||
bufferData[outputPos++] =data[inputPos++]/1000; | ||
bufferData[outputPos++] =data[inputPos++]/1000; | ||
bufferData[outputPos++] =0; | ||
} | ||
this.numInstances =size | ||
this.numDrawInstances=size | ||
this.numDrawInstancesMax=size; | ||
this.createBuffer( bufferData, "instanceBuffer") | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Renderer from "../lib/Renderer"; | ||
import PreLoader from "../lib/PreLoader"; | ||
import DrawingLoader from "./DrawingLoader"; | ||
import Drawing from "./Drawing"; | ||
|
||
|
||
export default class DrawingPreloader{ | ||
|
||
public drawings:Array<Drawing>=[] | ||
constructor() { | ||
|
||
} | ||
|
||
load(renderer:Renderer,preloader:PreLoader) { | ||
let drawings =["bird_birdHouse","fish_world","gooutside_door_HO","house_house","woods_world","demon_world","demonback_world","nice_world"]; | ||
|
||
for(let files of drawings){ | ||
|
||
let name = "drawings/"+files+".bin"; | ||
|
||
let drawing = new DrawingLoader(renderer,preloader,name); | ||
this.drawings.push(drawing) | ||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters