Giter Club home page Giter Club logo

canvas-lv's Introduction

用three.js魔改canvas 2d

canvas原生架构的意义

1.可视化需求千变万化,现有的图形框架不一定能满足你的需求。

2.有些以可视化为主导的项目,比如线上服装图案的设计、物流公司的仓储可视化,它们的项目复杂度高、灵活度都挺高,现有的图形框架即使能暂时满足你的基本需求,也很难满足你的后期维护和功能拓展需求。

3.canvas 适合非三维、图形数量不是太多的项目,因为它相较于WebGL更易上手,架构周期也短。

canvas 架构目的的定位

1.首先不要奢望架构100%完美的canvas框架,比如用它来架构一个光栅引擎出来,可以深度测试,可以写shader,可以实现一个非常逼真的三维场景。这种架构玩玩还可以,但是其底层的GPU 渲染规则决定了canvas 不能做基于片元的并行渲染。canvas只能做基于片元的同步渲染,那会很慢的。

2.基于项目需求,有目的的架构canvas。比如有的项目只需要有二维拼图功能就可以了,那就做好图形的模块化;有的项目会用点线做一些炫酷的三维效果,那就需要架构好变换矩阵。

项目需求:

  • 点、线的三维变换。

  • 圆形、矩形、弧线、曲线等基本图形的绘制。

  • 文字的绘制。

  • 图像的绘制。

  • 图形的选择。

  • 图形绘制顺序的设置。

文件结构

  • jsm 组件
    • core 核心组件
    • cameras 相机,源自three.js
    • objects 图形
    • extras 路径,源自three.js
    • img 图像
    • math 数学算法,源自three.js
    • utils 常用方法
  • example 案例文件
  • test 测试文件

canvas-lv's People

Contributors

buglas8888 avatar

Stargazers

happylusn avatar withoutRock avatar DivFloat avatar Jack traveler avatar

Watchers

buglas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.