-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More examples, elementFactory width/height
Signed-off-by: Jan Fischer <info@bitworking.de>
- Loading branch information
1 parent
1231d04
commit cab27c9
Showing
10 changed files
with
303 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -41,8 +41,10 @@ | |
} | ||
|
||
.slider { | ||
/* | ||
width: 960px; | ||
height: 300px; | ||
height: 300px; | ||
*/ | ||
} | ||
|
||
#footer { | ||
|
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,76 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script src="../release/css3d.min.js"></script> | ||
|
||
|
||
<style> | ||
body { | ||
margin: 0; | ||
font-family: sans-serif; | ||
} | ||
|
||
#container { | ||
width: 500px; | ||
height: 500px; | ||
margin: auto auto; | ||
margin-top: 300px; | ||
position: relative; | ||
} | ||
|
||
.cube { | ||
background-color: #999; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
|
||
</div> | ||
|
||
<script> | ||
|
||
var container = document.getElementById('container'); | ||
|
||
// init engine and scene | ||
var engine = new css3d(container); | ||
var scene = new css3d.scene(); | ||
|
||
var cube01 = css3d.elementFactory.cube(container, scene, 300, null, 'cube'); | ||
|
||
var cube02 = css3d.elementFactory.cube(container, scene, 200, null, 'cube'); | ||
cube02.setTranslation(-600, 0, 0); | ||
cube02.setParent(cube01); | ||
|
||
var cube03 = css3d.elementFactory.cube(container, scene, 100, null, 'cube'); | ||
cube03.setTranslation(-200, 0, 0); | ||
cube03.setParent(cube02); | ||
|
||
// add scene to engine | ||
engine.setScene(scene); | ||
|
||
if (!engine.browserSupports3d) { | ||
alert('This browser does not support CSS 3D'); | ||
} | ||
|
||
var axis = new css3d.vector3(0.2, 1, 0).normalize(); | ||
var angle = 0; | ||
|
||
engine.onRender = updateScene; | ||
engine.startRender(); | ||
|
||
function updateScene(deltaTime) | ||
{ | ||
cube01.setRotation(axis, -angle); | ||
cube02.setRotation(axis, -angle*2); | ||
cube03.setRotation(axis, -angle*3); | ||
angle += 0.01; | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
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,140 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script src="../release/css3d.min.js"></script> | ||
|
||
|
||
<style> | ||
body { | ||
margin: 0; | ||
font-family: sans-serif; | ||
overflow: hidden; | ||
} | ||
|
||
#container { | ||
width: 500px; | ||
height: 500px; | ||
margin: auto auto; | ||
margin-top: 300px; | ||
position: relative; | ||
} | ||
|
||
.skybox { | ||
background-image: url('../textures/skybox.png'); | ||
position: absolute; | ||
} | ||
|
||
.skybox.skybox-back { | ||
background-position: -1024px -1024px; | ||
} | ||
|
||
.skybox.skybox-front { | ||
background-position: -3072px -1024px; | ||
} | ||
|
||
.skybox.skybox-left { | ||
background-position: 0px -1024px; | ||
} | ||
|
||
.skybox.skybox-right { | ||
background-position: -2048px -1024px; | ||
} | ||
|
||
.skybox.skybox-top { | ||
background-position: -1024px 0px; | ||
} | ||
|
||
.skybox.skybox-bottom { | ||
background-position: -1024px -2048px; | ||
} | ||
|
||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
|
||
</div> | ||
|
||
<script> | ||
|
||
var container = document.getElementById('container'); | ||
|
||
// init engine and scene | ||
var engine = new css3d(container); | ||
var scene = new css3d.scene(); | ||
scene.getCamera().setTranslation(0, 0, 0); | ||
|
||
var skybox = css3d.elementFactory.skybox(container, scene, 1024, null, 'skybox'); | ||
|
||
// add scene to engine | ||
engine.setScene(scene); | ||
|
||
if (!engine.browserSupports3d) { | ||
alert('This browser does not support CSS 3D'); | ||
} | ||
|
||
var axis = new css3d.vector3(0.2, 1, 0).normalize(); | ||
var angle = 0; | ||
|
||
var engineDeltaTime = 0; | ||
|
||
engine.onRender = updateScene; | ||
engine.update().render(); | ||
|
||
|
||
function updateScene(deltaTime) | ||
{ | ||
engineDeltaTime = deltaTime; | ||
} | ||
|
||
/* mouse events */ | ||
|
||
var cameraRotationX = 0; | ||
var cameraRotationY = 0; | ||
var cameraRotationAxis = new css3d.vector3(0, -1, 0).normalize(); | ||
|
||
var lastXY = null; | ||
|
||
document.onmousedown = function(evt) | ||
{ | ||
lastXY = null; | ||
document.addEventListener('mousemove', onMouseMove); | ||
engine.startRender(); | ||
}; | ||
|
||
document.onmouseup = function(evt) | ||
{ | ||
document.removeEventListener('mousemove', onMouseMove); | ||
engine.stopRender(); | ||
}; | ||
|
||
function onMouseMove(evt) | ||
{ | ||
var x = evt.pageX; | ||
var y = evt.pageY; | ||
var relX, relY; | ||
|
||
if (null == lastXY) { | ||
lastXY = [x, y]; | ||
return; | ||
} | ||
|
||
relX = x - lastXY[0]; | ||
relY = lastXY[1] - y; | ||
|
||
cameraRotationX += (relY/100 * engineDeltaTime); | ||
cameraRotationY += (relX/100 * engineDeltaTime); | ||
|
||
scene.getCamera().setRotationXYZ(-cameraRotationX, -cameraRotationY, 0); | ||
|
||
lastXY = [x, y]; | ||
|
||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.