-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
91 lines (84 loc) · 2.41 KB
/
index.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
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>demo</title>
<script src="lib/core/ht.js"></script>
<script src="lib/plugin/ht-form.js"></script>
<script src="lib/plugin/ht-modeling.js"></script>
<script>
function init() {
ht.Default.setImage('door', 'res/wall.jpg');
var g3d = new ht.graph3d.Graph3dView();
var view = g3d.getView();
g3d.addToDOM();
view.style.background = "#222222";
var dataModel = g3d.dm();
g3d.isMovable = function() { return false; };
// 创建墙体
var wall = new ht.CSGShape();
wall.setClosePath(true);
wall.setTall(240);
wall.setElevation(120);
wall.setThickness(20);
wall.setPoints([
{ x: -400, y: -600 },
{ x: 400, y: -600 },
{ x: 400, y: 480 },
{ x: 200, y: 480 },
{ x: 200, y: 600 },
{ x: -400, y: 600 }
]);
wall.s({
"shape.border.width": 20,
// "shape.border.color": "#898989",
"all.color": "#5D5D5D",
"front.color": "lightgray",
"back.color": "lightgray",
// "csg.color": "#DDDDDD"
});
dataModel.add(wall);
// 地板
var floor = new ht.Shape();
floor.setClosePath(true);
floor.setThickness(-1);
floor.setTall(1);
floor.setElevation(-0.51);
floor.setPoints([
{x: -400, y: -600},
{x: 400, y: -600},
{x: 400, y: 480},
{x: 200, y: 480},
{x: 200, y: 600},
{x: -400, y: 600}
]);
floor.s({
'repeat.uv.length': 40,
'shape.border.width': 0,
'shape3d.top.image': 'res/wall.jpg'
});
floor.a({'all.color': 'red'})
console.log(floor);
dataModel.add(floor);
// 门
var door = new ht.DoorWindow();
door.setTall(200);
door.setElevation(100);
door.setWidth(100);
door.setHost(wall);
door.s({
'attach.index': 2,
'attach.offset': 100,
'attach.offset.opposite': true,
'dw.axis': 'left',
'all.image': 'door',
'front.uv': [1,0, 1,1, 0,1, 0,0]
});
dataModel.add(door);
var node = new ht.Node();
}
</script>
</head>
<body onload="init();">
</body>
</html>