Skip to content

Commit

Permalink
merged with mod-conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcliffe committed Jul 6, 2011
2 parents 34d9213 + 6b13dde commit 7b0d44f
Show file tree
Hide file tree
Showing 32 changed files with 13,178 additions and 12,978 deletions.
13,081 changes: 114 additions & 12,967 deletions CubicVR.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions HEADER
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Javascript port of CubicVR 3D engine for WebGL
by Charles J. Cliffe
http://www.cubicvr.org/

May be used under the terms of the MIT license.
http://www.opensource.org/licenses/mit-license.php
*/

/*globals alert: false */
59 changes: 50 additions & 9 deletions Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,15 +2,50 @@
CUBICVR := CubicVR CUBICVR := CubicVR
SRC_DIR := . SRC_DIR := .
DIST_DIR := $(SRC_DIR)/dist DIST_DIR := $(SRC_DIR)/dist
CUBICVR_SRC := $(SRC_DIR)/$(CUBICVR).js
CUBICVR_DIST := $(DIST_DIR)/$(CUBICVR).js CUBICVR_DIST := $(DIST_DIR)/$(CUBICVR).js
CUBICVR_MIN := $(DIST_DIR)/$(CUBICVR).min.js CUBICVR_MIN := $(DIST_DIR)/$(CUBICVR).min.js
CUBICVR_CORE := $(SRC_DIR)/CubicVR.js
CUBICVR_VS := $(SRC_DIR)/$(CUBICVR)_Core.vs CUBICVR_VS := $(SRC_DIR)/$(CUBICVR)_Core.vs
CUBICVR_FS := $(SRC_DIR)/$(CUBICVR)_Core.fs CUBICVR_FS := $(SRC_DIR)/$(CUBICVR)_Core.fs
TOOLS_DIR := $(SRC_DIR)/tools TOOLS_DIR := $(SRC_DIR)/tools
TESTS_DIR := $(DIST_DIR)/tests TESTS_DIR := $(DIST_DIR)/tests
SOURCE_DIR := $(SRC_DIR)/source


compile = java -jar $(TOOLS_DIR)/closure/compiler.jar --js $(CUBICVR_DIST) \ JS_SRCS := \
$(SOURCE_DIR)/CubicVR.COLLADA.js \
$(SOURCE_DIR)/CubicVR.CVRXML.js \
$(SOURCE_DIR)/CubicVR.Camera.js \
$(SOURCE_DIR)/CubicVR.GML.js \
$(SOURCE_DIR)/CubicVR.Landscape.js \
$(SOURCE_DIR)/CubicVR.Layout.js \
$(SOURCE_DIR)/CubicVR.Light.js \
$(SOURCE_DIR)/CubicVR.MainLoop.js \
$(SOURCE_DIR)/CubicVR.Material.js \
$(SOURCE_DIR)/CubicVR.Math.js \
$(SOURCE_DIR)/CubicVR.Mesh.js \
$(SOURCE_DIR)/CubicVR.Motion.js \
$(SOURCE_DIR)/CubicVR.Octree.js \
$(SOURCE_DIR)/CubicVR.Particles.js \
$(SOURCE_DIR)/CubicVR.PostProcess.js \
$(SOURCE_DIR)/CubicVR.Primitives.js \
$(SOURCE_DIR)/CubicVR.Renderer.js \
$(SOURCE_DIR)/CubicVR.Scene.js \
$(SOURCE_DIR)/CubicVR.Shader.js \
$(SOURCE_DIR)/CubicVR.Texture.js \
$(SOURCE_DIR)/CubicVR.UVMapper.js \
$(SOURCE_DIR)/CubicVR.Utility.js \
$(SOURCE_DIR)/CubicVR.Worker.js

cutcore = ( python $(TOOLS_DIR)/cutter.py $(1) )

addheader = @@cat $(SRC_DIR)/HEADER > $(DIST_DIR)/header.tmp && \
cat $(1) >> $(DIST_DIR)/header.tmp && \
rm -f $(1) && \
mv $(DIST_DIR)/header.tmp $(1)

compile = java -jar $(TOOLS_DIR)/closure/compiler.jar \
--js $(CUBICVR_CORE) \
$(shell for js in $(JS_SRCS) ; do echo --js $$js ; done) \
--compilation_level SIMPLE_OPTIMIZATIONS \ --compilation_level SIMPLE_OPTIMIZATIONS \
--js_output_file $(1) --js_output_file $(1)


Expand All @@ -22,19 +57,25 @@ stringify = ( echo '/* Auto Embed $(2) */' ; \
all: $(DIST_DIR) $(CUBICVR_DIST) $(CUBICVR_MIN) all: $(DIST_DIR) $(CUBICVR_DIST) $(CUBICVR_MIN)
@@echo "Finished, see $(DIST_DIR)" @@echo "Finished, see $(DIST_DIR)"


$(DIST_DIR): $(CUBICVR_DIST): $(DIST_DIR) $(JS_SRCS)
@@echo "Creating $(DIST_DIR)"
@@mkdir $(DIST_DIR)

$(CUBICVR_DIST): $(DIST_DIR) $(CUBICVR_SRC)
@@echo "Building $(CUBICVR_DIST)" @@echo "Building $(CUBICVR_DIST)"
@@cp $(CUBICVR_SRC) $(CUBICVR_DIST) @@$(call cutcore, $(CUBICVR_CORE)) > $(CUBICVR_DIST)
@@cat $(JS_SRCS) >> $(CUBICVR_DIST)
@@$(call cutfile,$(CUBICVR_DIST))
@@$(call stringify,CubicVRCoreVS,$(CUBICVR_VS)) >> $(CUBICVR_DIST) @@$(call stringify,CubicVRCoreVS,$(CUBICVR_VS)) >> $(CUBICVR_DIST)
@@$(call stringify,CubicVRCoreFS,$(CUBICVR_FS)) >> $(CUBICVR_DIST) @@$(call stringify,CubicVRCoreFS,$(CUBICVR_FS)) >> $(CUBICVR_DIST)
@@$(call addheader,$(CUBICVR_DIST))

$(DIST_DIR):
@@echo "Creating $(DIST_DIR)"
@@mkdir $(DIST_DIR)


$(CUBICVR_MIN): $(DIST_DIR) $(CUBICVR_SRC) $(CUBICVR_DIST) $(CUBICVR_MIN): $(DIST_DIR) $(CUBICVR_DIST)
@@echo "Building $(CUBICVR_MIN)" @@echo "Building $(CUBICVR_MIN)"
@@$(call compile,$(CUBICVR_MIN)) @@$(call compile,$(CUBICVR_MIN))
@@$(call addheader,$(CUBICVR_MIN))
@@$(call stringify,CubicVRCoreVS,$(CUBICVR_VS)) >> $(CUBICVR_MIN)
@@$(call stringify,CubicVRCoreFS,$(CUBICVR_FS)) >> $(CUBICVR_MIN)


tests: $(DIST_DIR) $(CUBICVR_MIN) tests: $(DIST_DIR) $(CUBICVR_MIN)
@@echo "Creating tests in $(TESTS_DIR)" @@echo "Creating tests in $(TESTS_DIR)"
Expand Down
13 changes: 12 additions & 1 deletion README.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Javascript Port of the [CubicVR 3D Engine](http://www.cubicvr.org) by Charles J.


### Folders ### ### Folders ###


/ -> core library (to be included as submodule) / -> core library and shaders
/source -> source modules
/editor -> web-based 3D editor (work in progress)
/samples -> sample projects, useful as a starting point /samples -> sample projects, useful as a starting point
/tests -> tests and prototypes for various core features /tests -> tests and prototypes for various core features
/lib -> external dependencies for any tests/examples /lib -> external dependencies for any tests/examples
Expand All @@ -31,3 +33,12 @@ Javascript Port of the [CubicVR 3D Engine](http://www.cubicvr.org) by Charles J.
### Branches ### ### Branches ###


master -> main branch master -> main branch

### Building / Minification ###

To build the consolidated and minified versions of CubicVR.js simply run "make" in the repository root.

The resulting CubicVR.js and CubicVR.min.js builds with self-contained core shaders will be placed in dist/

Minification requires Python and Java to be installed, please review installation instructions for your platform.

2 changes: 1 addition & 1 deletion samples/basic/basic_primitives.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@


<body onLoad="webGLStart();"></body> <body onLoad="webGLStart();"></body>


</html> </html>
71 changes: 71 additions & 0 deletions samples/collada/wall_smash_cam_attach.html
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>

<head>
<title>
CubicVR.js: Using a COLLADA scene from a .dae file
</title>
<script src="../../CubicVR.js" type="text/javascript">
</script>
<script type='text/javascript'>
function webGLStart() {
// by default generate a full screen canvas with automatic resize
var gl = CubicVR.init();
var canvas = CubicVR.getCanvas();

if (!gl) {
alert("Sorry, no WebGL support.");
return;
};

// load the collada file, specify path for images
var scene = CubicVR.loadCollada("WallSmash/wall_smash.dae","WallSmash/");
scene.resize(canvas.width,canvas.height);
// scene.camera.position = [20,20,-20]; // set our camera position
// scene.camera.target = [0,5,-5]; // set our camera position
scene.camera.position = [0,1,3.5];
scene.camera.rotation = [0,0,0];
scene.camera.targeted = false;
scene.camera.setParent(scene.getSceneObject("Sphere"));
scene.camera.motion = null; // remove any camera motion
scene.lights = []; // clear the loaded lights

// Add a simple shadowed directional light
scene.bindLight(new CubicVR.Light({
type:CubicVR.enums.light.type.AREA,
distance:90,
areaCeiling:90,
specular:[1,1,1],
areaAxis:[-25,-10]
}));

CubicVR.setSoftShadows(true);

// Add our scene to the window resize list
CubicVR.addResizeable(scene);

// Use a basic envelope to loop/stretch the time
var looper = new CubicVR.Envelope({
in_behavior:CubicVR.enums.envelope.behavior.REPEAT,
out_behavior:CubicVR.enums.envelope.behavior.REPEAT
});
looper.addKey(0,0);
looper.addKey(10,10);
looper.addKey(15,0);

// Start our main drawing loop, it provides a timer and the gl context as parameters
CubicVR.MainLoop(function(timer, gl) {
scene.evaluate(looper.evaluate(timer.getSeconds()));
scene.updateShadows();
scene.render();
});

// initialize a mouse view controller
mvc = new CubicVR.MouseViewController(canvas, scene.camera);
}
</script>
</head>

<body onLoad="webGLStart();"></body>

</html>
Loading

0 comments on commit 7b0d44f

Please sign in to comment.