Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize onframe Walking along the Line by js

Shulou Source: shulou.com Published: 2022-06-01 07:06:40 10月03日 Update

This article mainly introduces "how to realize the onframe walking along the js". In the daily operation, I believe many people have doubts about how to realize the onframe walking along the js. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize the onframe walking along the js". Next, please follow the editor to study!

The following is a list of a practical application, how to move a model file dynamically online along a well-made line.

Here is the specific js code:

/ / A general function, how to convert the point type of geometry in te into position position

Function pointToPostion (point,altitudeType)

{

Var postionl=SGWorld.Creator.CreatePosition (point.X,point.Y,point.Z,altitudeType,0,0,0,0)

Return postionl

}

/ / define walking model, time and other parameters

Var model = null

Var time

Var linePointCount=0

Var i

Var altitudeType

Var linePoint

Function Init ()

{

ITunes 0

/ / find the pre-drawn line object

Var item = SGWorld.ProjectTree.FindItem ("Line\\ path")

Var poly = SGWorld.ProjectTree.GetObject (item)

/ / get the geometry and height type of the line object, and the points contained in the line

Var polygonGeometry = poly.Geometry

AltitudeType=poly.Position.AltitudeType

LinePoint= polygonGeometry.Points

LinePointCount=polygonGeometry.Points.Count

Var fpos=pointToPostion (linePoint.Item (I), altitudeType)

/ / initialization time and onframe event

Time = new Date ()

SGWorld.AttachEvent ("onFrame", onFrame); / / create a new walking model

Model = SGWorld.Creator.CreateModel (fpos, "D:\\ skylinedata\\ villain .xpl", 3)

}

/ / onframe time implementation, which is the key to the code

Function onFrame ()

{

/ / Walk according to the points in the line, from the first point to the last one. When the point is greater than the number of points, the path is finished.

If (I)

Tags: Along the line time model learning object code location more type path switch help utility next event key function front point dynamic parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Shulou Information MySQL Shulou Tech Info