Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Schmithüsen committed Jan 21, 2019
1 parent 0008c1d commit faa8ab4
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 83 deletions.
6 changes: 0 additions & 6 deletions src/accessor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { initGlForMembers } from './utils.js';
import { WebGl } from './webgl.js';
import { GltfObject } from './gltf_object.js';

Expand All @@ -23,11 +22,6 @@ class gltfAccessor extends GltfObject
this.typedView = undefined;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

getTypedView(gltf)
{
if (this.typedView !== undefined)
Expand Down
7 changes: 1 addition & 6 deletions src/buffer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from '../libs/axios.min.js';
import { getContainingFolder, initGlForMembers } from './utils.js';
import { getContainingFolder } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfBuffer extends GltfObject
Expand All @@ -15,11 +15,6 @@ class gltfBuffer extends GltfObject
this.buffer = undefined; // raw data blob
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

load(gltf, additionalFiles = undefined)
{
if (this.buffer !== undefined)
Expand Down
6 changes: 0 additions & 6 deletions src/buffer_view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { initGlForMembers } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfBufferView extends GltfObject
Expand All @@ -13,11 +12,6 @@ class gltfBufferView extends GltfObject
this.target = undefined;
this.name = undefined;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}
}

export { gltfBufferView };
41 changes: 19 additions & 22 deletions src/camera.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { mat4, vec3, quat } from 'gl-matrix';
import { fromKeys, initGlForMembers } from './utils.js';
import { fromKeys } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfCamera
class gltfCamera extends GltfObject
{
constructor(
type = "perspective",
Expand All @@ -14,6 +15,7 @@ class gltfCamera
name = undefined,
nodeIndex = undefined)
{
super();
this.type = type;
this.znear = znear;
this.zfar = zfar;
Expand All @@ -25,6 +27,21 @@ class gltfCamera
this.node = nodeIndex;
}

fromJson(jsonCamera)
{
this.name = name;
if(jsonCamera.perspective !== undefined)
{
this.type = "perspective";
fromKeys(this, jsonCamera.perspective);
}
else if(jsonCamera.orthographic !== undefined)
{
this.type = "orthographic";
fromKeys(this, jsonCamera.orthographic);
}
}

sortNodesByDepth(nodes)
{
// precompute the distances to avoid their computation during sorting
Expand Down Expand Up @@ -128,26 +145,6 @@ class gltfCamera
{
return gltf.nodes[this.node];
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

fromJson(jsonCamera)
{
this.name = name;
if(jsonCamera.perspective !== undefined)
{
this.type = "perspective";
fromKeys(this, jsonCamera.perspective);
}
else if(jsonCamera.orthographic !== undefined)
{
this.type = "orthographic";
fromKeys(this, jsonCamera.orthographic);
}
}
}

export { gltfCamera };
3 changes: 1 addition & 2 deletions src/gltf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class glTF

initGl()
{
this.addNodeReferences();
initGlForMembers(this, this);
}

Expand All @@ -58,8 +59,6 @@ class glTF
this.materials.push(gltfMaterial.createDefault());
this.samplers.push(gltfSampler.createDefault());

this.addNodeReferences();

if (json.scenes !== undefined)
{
if (json.scene === undefined && json.scenes.length > 0)
Expand Down
14 changes: 7 additions & 7 deletions src/image.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { HDRImage } from '../libs/hdrpng.js';
import { initGlForMembers } from './utils.js';
import { WebGl } from './webgl.js';
import { GltfObject } from './gltf_object.js';

const ImageMimeType = {JPEG: "image/jpeg", HDR: "image/vnd.radiance"};

class gltfImage extends GltfObject
{
constructor(uri = undefined, type = WebGl.context.TEXTURE_2D, miplevel = 0, bufferView = undefined, name = undefined, mimeType = ImageMimeType.JPEG, image = undefined)
constructor(
uri = undefined,
type = WebGl.context.TEXTURE_2D, miplevel = 0,
bufferView = undefined,
name = undefined,
mimeType = ImageMimeType.JPEG,
image = undefined)
{
super();
this.uri = uri;
Expand All @@ -23,11 +28,6 @@ class gltfImage extends GltfObject
this.miplevel = miplevel; // nonstandard
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

resolveRelativePath(basePath)
{
if (this.uri !== undefined)
Expand Down
7 changes: 1 addition & 6 deletions src/light.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mat4, vec2, vec3, quat } from 'gl-matrix';
import { jsToGl, UniformStruct, initGlForMembers } from './utils.js';
import { jsToGl, UniformStruct } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfLight extends GltfObject
Expand All @@ -19,11 +19,6 @@ class gltfLight extends GltfObject
this.node = undefined;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

toUniform(gltf)
{
const uLight = new UniformLight();
Expand Down
2 changes: 1 addition & 1 deletion src/material.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mat3, vec3, vec4 } from 'gl-matrix';
import { gltfTextureInfo } from './texture.js';
import { fromKeys, jsToGl, initGlForMembers } from './utils.js';
import { jsToGl, initGlForMembers } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfMaterial extends GltfObject
Expand Down
11 changes: 4 additions & 7 deletions src/mesh.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { gltfPrimitive } from './primitive.js';
import { initGlForMembers, objectsFromJsons } from './utils.js';
import { objectsFromJsons } from './utils.js';
import { GltfObject } from './gltf_object.js';

class gltfMesh
class gltfMesh extends GltfObject
{
constructor()
{
super();
this.primitives = [];
this.name = undefined;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

fromJson(jsonMesh)
{
if (jsonMesh.name !== undefined)
Expand Down
11 changes: 4 additions & 7 deletions src/node.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { mat4, vec3, vec4 } from 'gl-matrix';
import { jsToGl, initGlForMembers } from './utils.js';
import { jsToGl } from './utils.js';
import { GltfObject } from './gltf_object.js';

// contain:
// transform
// child indices (reference to scene array of nodes)

class gltfNode
class gltfNode extends GltfObject
{
constructor()
{
super();
this.camera = undefined;
this.children = [];
this.matrix = undefined;
Expand All @@ -25,11 +27,6 @@ class gltfNode
this.changed = true;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

fromJson(jsonNode)
{
if (jsonNode.name !== undefined)
Expand Down
6 changes: 0 additions & 6 deletions src/sampler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { initGlForMembers } from './utils.js';
import { WebGl } from './webgl.js';
import { GltfObject } from './gltf_object.js';

Expand All @@ -22,11 +21,6 @@ class gltfSampler extends GltfObject
{
return new gltfSampler();
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}
}

export { gltfSampler };
10 changes: 3 additions & 7 deletions src/scene.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { mat4 } from 'gl-matrix';
import { initGlForMembers } from './utils';
import { GltfObject } from './gltf_object';

class gltfScene
class gltfScene extends GltfObject
{
constructor(nodes = [], name = undefined)
{
super();
this.nodes = nodes;
this.name = name;
}

initGl(gltf)
{
initGlForMembers(this, gltf);
}

fromJson(jsonScene)
{
if (jsonScene.nodes !== undefined)
Expand Down

0 comments on commit faa8ab4

Please sign in to comment.