Skip to content

Commit

Permalink
updating examples to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschmann committed Jul 4, 2024
1 parent be31568 commit b2aac9e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions examples/3d/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import {OrbitControls} from "three-orbitcontrols"


class State{
constructor(canvas, parameters, {devicePixelRatio}){
constructor(canvas, {devicePixelRatio}){
this.canvas = canvas
this.devicePixelRatio = devicePixelRatio
this.parameters = parameters
}
async initialize(){
const width = this.canvas.width
Expand All @@ -18,8 +17,7 @@ class State{
this.renderer.setClearColor(0xffffff, 0);
this.renderer.setSize(width/this.devicePixelRatio, height/this.devicePixelRatio);
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
this.box = new THREE.Mesh(new THREE.BoxGeometry(this.parameters.depth, this.parameters.height, this.parameters.width), new THREE.MeshLambertMaterial({color: 0x00FF00}));
this.scene.add(this.box)
this.box = null
var light = new THREE.AmbientLight(0xffffff, 0.5);
this.scene.add(light);
let intensity = 0.2;
Expand All @@ -39,6 +37,13 @@ class State{
}

}
export async function episode_init(ui_state, parameters){
if(ui_state.box){
ui_state.scene.remove(ui_state.box)
}
ui_state.box = new THREE.Mesh(new THREE.BoxGeometry(parameters.depth, parameters.height, parameters.width), new THREE.MeshLambertMaterial({color: 0x6fd0cb})); //0x00FF00}));
ui_state.scene.add(ui_state.box)
}
export async function init(canvas, parameters, options){
const state = new State(canvas, parameters, options)
await state.initialize()
Expand Down
2 changes: 1 addition & 1 deletion examples/bottleneck/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function init(canvas, parameters, options){
export async function init(canvas, options){
// Simply saving the context for 2D environments
return {
ctx: canvas.getContext('2d')
Expand Down
1 change: 0 additions & 1 deletion examples/l2f/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export async function render(ui_state, parameters, state, action) {
ui_state.drone.drone.quaternion.copy(new THREE.Quaternion(state.orientation[1], state.orientation[2], state.orientation[3], state.orientation[0]).normalize())
const width = ui_state.canvas.width/ui_state.devicePixelRatio
const height = ui_state.canvas.height/ui_state.devicePixelRatio
console.log("Setting size to ", width, height)
ui_state.camera.aspect = width / height
ui_state.camera.updateProjectionMatrix()
ui_state.renderer.setPixelRatio(ui_state.devicePixelRatio)
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum-simple/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function init(canvas, parameters, options){
export async function init(canvas, options){
// Simply saving the context for 2D environments
return {
ctx: canvas.getContext('2d')
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export async function init(canvas, parameters, options){
export async function init(canvas, options){
// Simply saving the context for 2D environments
return {
ctx: canvas.getContext('2d')
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const current_version = "0.1.1"

window.addEventListener('load', () => {
let initFunction;
let episodeInitFunction;
Expand Down Expand Up @@ -368,7 +370,6 @@ window.addEventListener('load', () => {
forceReload = true;
// topSection.style.height = `80vh`;
}
const current_version = "0.1.0"
if(localStorage.getItem("version") !== current_version){
forceReload = true;
localStorage.setItem("version", current_version)
Expand Down

0 comments on commit b2aac9e

Please sign in to comment.