基于 HTML5 Canvas 的 3D 渲染引擎界面以及吸附等效果的运用


当前第2页 返回上一页

下面我们来一起创建模型吧!分别是地板 floor,桌面 table,四个桌腿以及盒子:

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

// 地板

floor = createNode([0, 0, 0], [600, 5, 400]).s({

  'all.color': '#A0A0A0',// 六面颜色

  'label': '地板',// 图元文字内容

  'label.face': 'top',// 文字在3d下的朝向,可取值(left|right|top|bottom|front|back|center)

  'label.background': 'yellow',// 图元文字背景

  'label.position': 22,// 图元文字位置

  'label.t3': [10, 0, -10],// 文字在3d下的偏移,格式为 [x,y,z]

  'label.font': '28px arial, sans-serif'// 图元文字字体

});

// 桌面

table = createNode([0, 120, 0], [400, 10, 280], floor).s({

  'shape3d': 'cylinder',// 为空时显示为六面立方体,cylinder 圆柱

  'shape3d.side': 60,// 决定 3d 图形显示为几边型,为 0 时显示为平滑的曲面效果

  'shape3d.color': '#E5BB77',// 3d 图形整体颜色

  'label': '桌子',

  'label.face': 'top',

  'label.background': 'yellow',

  'label.position': 23,

  'label.t3': [0, 0, -10],

  'label.font': '20px arial, sans-serif'

});

// 四个桌腿

foot1 = createNode([100, 60, 80], [20, 110, 20], table).s({

  'shape3d': 'cylinder',

  'shape3d.color': '#E5BB77',

});

foot2 = createNode([-100, 60, 80], [20, 110, 20], table).s({

  'shape3d': 'cylinder',

  'shape3d.color': '#E5BB77',

});

foot3 = createNode([100, 60, -80], [20, 110, 20], table).s({

  'shape3d': 'cylinder',

  'shape3d.color': '#E5BB77',

});

foot4 = createNode([-100, 60, -80], [20, 110, 20], table).s({

  'shape3d': 'cylinder',

  'shape3d.color': '#E5BB77',

});

// 盒子

box = createNode([0, 150, 0], [100, 50, 60], table).s({

  'all.color': '#2e2f32',

  'front.color': '#BDC3C7',// 前面颜色

  'note': '盯着你看', // 图元冒泡标注

  'note.face': 'top',

  'note.position': 7,

  'note.t3': [0, 0, 10],

  'note.autorotate': true// 图标在 3D 下是否自动朝向眼睛的方向

});

代码中有一些属性,我已经帮大家写好了详细的注释。在此献上各种关于 'shape3d' 的图形的值,方便大家玩耍:

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。更多相关教程请访问Html5视频教程!

相关推荐:

HTML5图文教程

HTML5在线手册

html5特效代码大全

以上就是基于 HTML5 Canvas 的 3D 渲染引擎界面以及吸附等效果的运用的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

HTML5 touch事件实现触屏页面上下滑动(一)

HTML5能干什么的

HTML5 canvas实现中奖转盘的实例代码

HTML5新增标签有哪些

用canvas实现简单的下雪效果(附代码)

企业开发中使用h5有哪些注意事项

HTML5实现拖拽功能步骤详解

h5 canvas中fill 与stroke文字效果实现实例

HTML5新增了哪些input类型及其属性?

HTML5百叶窗效果的示例代码_HTML5教程技巧

更多相关阅读请进入《HTML5》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...