3JS tends to create what are called canonical objects. This is where you create
an object centered around the origin and then apply a series of transforms to
move it into position. This is fine so far as it goes, but is sometimes awkward
when you want to perform particular kinds of modeling. For example, if I want to
make a model where I want chains of cones to build a tree, I might rather say
where I want each end of the cone to be located. This sort of modelling where I
run a program to generate an object is called procedural model. I want to orient
the cone, given the top and bottom locations. That'll be your task. In the
cullen routine the top and bottom variables are vector three positions given the
ends of the cone. You'll see documentation for the other variables in the code
itself. Your task is to implement the internals of this method. Actually, I
decided to simplify a major piece for you. Mainly because it has a special case
having to do with a cross product. I implemented this function myself. So your
job is to create the proper length cylinder and feed this method its axis
direction and center. When you get the answer right, you'll see this on your
screen. I gave a lot of test cones here, and in fact, a few of these revealed
some bugs in my own code when I was writing it. If you ever design a component
like this, they will be used by others. I highly recommend that you try to
create as many different types of test cases as you can.
three.jsでは単純な形状の
オブジェクトをよく生成します
原点を中心に生成したオブジェクトで
一連の変換を適用して移動します
今のところ支障ありませんが
特定のモデリングをする際に扱いにくいことがあります
例えばモデルを作り円すいをつないで
木の形にするとします
もしくは円すいの先端と底面の位置を決めると
言った方がいいかもしれません
プログラムを用いてオブジェクトを生成することを
プロシージャルモデリングといいます
先端と底面の位置を指定して
円すいの向きを決めてください
呼び出し関数のtopおよびbottom変数は
円すいの両端を定義する3次元ベクトルの位置です
他の変数もコードに記録されています
皆さんにはこのメソッドの中身を実装してもらいます
クロス積を使う特殊なケースが含まれるため
私が主要な部分を単純化しておきました
この関数は私が実装しました
皆さんは適切な高さの円柱を生成し
このメソッドに軸の方向と中心を入力してください
答えが正しければこのように表示されます
私は多くの円すいを作ってテストしましたが
いくつかのコードにバグが見つかりました
もし皆さんがこのようなコンポーネントを
いつかデザインするなら他の人が使うことを考慮して
できるだけたくさんのケースを想定し
テストを行いましょう