forked from xeolabs/scenejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas_transparent.html
85 lines (70 loc) · 2.68 KB
/
canvas_transparent.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<title>SceneJS Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
background-image: url(textures/cloudsBackground.jpg);
background-size: cover;
background-repeat: no-repeat;
}
</style>
<script src="../api/latest/scenejs.min.js"></script>
<link href="css/styles.css" rel="stylesheet"/>
</head>
<body>
<div id="infoLight">
<a href="http://scenejs.org">SceneJS</a> - scene with transparent canvas<br><br>
This technique, in which we layer a transparent canvas over a div containing an image, is faster<br>
than creating the background in the 3D scene because it avoids having to render fragments<br>
via the GPU for the background, ie. avoids all those background pixels going down the GPU pipeline.<br><br>
Note that since we didn't specify a canvas ID for the scene, the scene creates one automatically.<br>
</div>
<script>
// Demonstrates how to have a transparent canvas
// This example happens to have SceneJS automatically create the canvas, rather than
// linking to a specified canvas that's already in the document. Transparency will work
// exactly the same when linking your scene to a canvas that's already in the document.
// Point SceneJS to the bundled plugins
SceneJS.setConfigs({
pluginPath: "../api/latest/plugins"
});
// Create scene
var scene = SceneJS.createScene({
// Make canvas transparent
transparent: true,
nodes: [
// Mouse-orbited camera, defined by
// plugin in http://scenejs.org/api/latest/plugins/node/cameras/orbit.js
{
type: "cameras/orbit",
yaw: 30,
pitch: -30,
zoom: 10,
zoomSensitivity: 10.0,
spin: 0.1, // Slowly spin
nodes: [
{
type: "material",
color: { r: 0.5, g: 0.5, b: 0.6 },
nodes: [
// Teapot primitive, implemented by plugin at
// http://scenejs.org/api/latest/plugins/node/geometry/teapot.js
{
type: "geometry/teapot"
}
]
}
]
}
]
});
</script>
</body>
</html>