如何创建具有 2 个相同纹理边的 3D 点?

发布于 2024-10-08 15:19:27 字数 1349 浏览 3 评论 0原文

因此,我不使用 3D 引擎而是使用 Flash 中的引擎创建点云:

import flash.display.Bitmap;
import flash.display.BitmapData;

var bmd:BitmapData = new BitmapData(400,400,true,0x00000000);

var xn:Number;
var yn:Number;
var zn:Number;
var norm:Number;
var c1:Number;
var c2:Number;
var c3:Number;
var c4:Number;
var counter:int;
var color:uint;
while (counter < 20000)
{
    xn = Math.random() * 400;
    yn = Math.random() * 400;
    zn = Math.random() * 400;
    norm = Math.sqrt(xn * xn + yn * yn + zn * zn);
    c1 = (1 - norm / 200) * 255;
    c2 = (1 - norm / 250) * 255;
    c3 = Math.abs(xn) / norm * 255;
    c4 = Math.abs(yn) / norm * 255;
    color =  (c1 << 24 | c2 << 16 | c3 << 8 | c4);
    counter++;

    var pointGraphicData = new BitmapData(1,1,true,color);
    var pointGraphic:Bitmap = new Bitmap(pointGraphicData);

    pointGraphic.x = xn;
    pointGraphic.y = yn;
    pointGraphic.z = zn;
    addChild(pointGraphic);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove );
this.x = 150;
this.y = 150;
this.z = 450;
function handleMouseMove( event:MouseEvent ):void
{
    this.rotationX = 0 - event.localX;
    this.rotationY = 0 - event.localY;
    this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY ));
}

因此这是一个谨慎的简单代码。如何使我的观点有两个侧面或始终面向wiever?

So I create a points cloud using no 3d engines but one baked into flash:

import flash.display.Bitmap;
import flash.display.BitmapData;

var bmd:BitmapData = new BitmapData(400,400,true,0x00000000);

var xn:Number;
var yn:Number;
var zn:Number;
var norm:Number;
var c1:Number;
var c2:Number;
var c3:Number;
var c4:Number;
var counter:int;
var color:uint;
while (counter < 20000)
{
    xn = Math.random() * 400;
    yn = Math.random() * 400;
    zn = Math.random() * 400;
    norm = Math.sqrt(xn * xn + yn * yn + zn * zn);
    c1 = (1 - norm / 200) * 255;
    c2 = (1 - norm / 250) * 255;
    c3 = Math.abs(xn) / norm * 255;
    c4 = Math.abs(yn) / norm * 255;
    color =  (c1 << 24 | c2 << 16 | c3 << 8 | c4);
    counter++;

    var pointGraphicData = new BitmapData(1,1,true,color);
    var pointGraphic:Bitmap = new Bitmap(pointGraphicData);

    pointGraphic.x = xn;
    pointGraphic.y = yn;
    pointGraphic.z = zn;
    addChild(pointGraphic);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove );
this.x = 150;
this.y = 150;
this.z = 450;
function handleMouseMove( event:MouseEvent ):void
{
    this.rotationX = 0 - event.localX;
    this.rotationY = 0 - event.localY;
    this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY ));
}

so its a wary simple code. how to make my points have 2 sides or be always face to wiever?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晌融 2024-10-15 15:19:27

此链接有一个关于如何在球体表面上创建螺旋的 JavaScript 示例:

http://lines-about-to-be- generated.blogspot.com/2009/06/image-spiral-sphere.html

There's a javascript example of how to create a spiral on a sphere surface at this link:

http://lines-about-to-be-generated.blogspot.com/2009/06/image-spiral-sphere.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文