|
12 | 12 | ]
|
13 | 13 | },
|
14 | 14 | {
|
15 |
| - "cell_type": "code", |
16 |
| - "execution_count": null, |
| 15 | + "cell_type": "markdown", |
17 | 16 | "metadata": {},
|
18 |
| - "outputs": [], |
19 | 17 | "source": [
|
20 |
| - "#\n", |
21 |
| - "# BufferAttribute\n", |
22 |
| - "#" |
| 18 | + "## BufferAttribute" |
23 | 19 | ]
|
24 | 20 | },
|
25 | 21 | {
|
|
64 | 60 | ]
|
65 | 61 | },
|
66 | 62 | {
|
67 |
| - "cell_type": "code", |
68 |
| - "execution_count": null, |
| 63 | + "cell_type": "markdown", |
69 | 64 | "metadata": {},
|
70 |
| - "outputs": [], |
71 | 65 | "source": [
|
72 |
| - "#\n", |
73 |
| - "# BufferGeometry\n", |
74 |
| - "#" |
| 66 | + "## BufferGeometry" |
75 | 67 | ]
|
76 | 68 | },
|
77 | 69 | {
|
|
80 | 72 | "metadata": {},
|
81 | 73 | "outputs": [],
|
82 | 74 | "source": [
|
| 75 | + "scale_factor = 20\n", |
83 | 76 | "# Simple square\n",
|
84 | 77 | "vertices = BufferAttribute(\n",
|
85 |
| - " array=np.array([\n", |
86 |
| - " [-1.0, -1.0, 1.0],\n", |
87 |
| - " [ 1.0, -1.0, 1.0],\n", |
88 |
| - " [ 1.0, 1.0, 1.0],\n", |
| 78 | + " array=scale_factor * np.array([\n", |
| 79 | + " [-1.0, -1.0, 0.0],\n", |
| 80 | + " [ 1.0, -1.0, 0.0],\n", |
| 81 | + " [ 1.0, 1.0, 0.0],\n", |
89 | 82 | " \n",
|
90 |
| - " [ 1.0, 1.0, 1.0],\n", |
91 |
| - " [-1.0, 1.0, 1.0],\n", |
92 |
| - " [-1.0, -1.0, 1.0],\n", |
| 83 | + " [ 1.0, 1.0, 0.0],\n", |
| 84 | + " [-1.0, 1.0, 0.0],\n", |
| 85 | + " [-1.0, -1.0, 0.0],\n", |
93 | 86 | " ], dtype=np.float32),\n",
|
94 | 87 | " normalized=False)"
|
95 | 88 | ]
|
|
120 | 113 | "metadata": {},
|
121 | 114 | "outputs": [],
|
122 | 115 | "source": [
|
123 |
| - "vertices.array = np.array([\n", |
124 |
| - " [-1.0, -1.0, 1.0],\n", |
125 |
| - " [ 2.0, -2.0, 2.0],\n", |
126 |
| - " [ 1.0, 1.0, 1.0],\n", |
| 116 | + "vertices.array = scale_factor * np.array([\n", |
| 117 | + " [-1.0, -1.0, 0.0],\n", |
| 118 | + " [ 2.0, -2.0, 1.0],\n", |
| 119 | + " [ 1.0, 1.0, 0.0],\n", |
127 | 120 | " \n",
|
128 |
| - " [ 1.0, 1.0, 1.0],\n", |
129 |
| - " [-1.0, 1.0, 1.0],\n", |
130 |
| - " [-1.0, -1.0, 1.0],\n", |
| 121 | + " [ 1.0, 1.0, 0.0],\n", |
| 122 | + " [-1.0, 1.0, 0.0],\n", |
| 123 | + " [-1.0, -1.0, 0.0],\n", |
131 | 124 | " ])"
|
132 | 125 | ]
|
133 | 126 | },
|
|
137 | 130 | "metadata": {},
|
138 | 131 | "outputs": [],
|
139 | 132 | "source": [
|
140 |
| - "vertices.array = np.array([\n", |
| 133 | + "vertices.array = scale_factor * np.array([\n", |
| 134 | + " [-1.0, -1.0, 0.0],\n", |
| 135 | + " [ 1.0, -1.0, 0.0],\n", |
| 136 | + " [ 1.0, 1.0, 0.0],\n", |
| 137 | + " \n", |
| 138 | + " [ 1.0, 1.0, 0.0],\n", |
| 139 | + " [-1.0, 1.0, 0.0],\n", |
| 140 | + " [-1.0, -1.0, 0.0],\n", |
| 141 | + " ])" |
| 142 | + ] |
| 143 | + }, |
| 144 | + { |
| 145 | + "cell_type": "code", |
| 146 | + "execution_count": null, |
| 147 | + "metadata": {}, |
| 148 | + "outputs": [], |
| 149 | + "source": [ |
| 150 | + "print(repr(geometry))" |
| 151 | + ] |
| 152 | + }, |
| 153 | + { |
| 154 | + "cell_type": "markdown", |
| 155 | + "metadata": {}, |
| 156 | + "source": [ |
| 157 | + "### Index attribute" |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": null, |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [ |
| 166 | + "# Simple square with unique vertices\n", |
| 167 | + "vertices = BufferAttribute(\n", |
| 168 | + " array=np.array([\n", |
141 | 169 | " [-1.0, -1.0, 1.0],\n",
|
142 | 170 | " [ 1.0, -1.0, 1.0],\n",
|
143 | 171 | " [ 1.0, 1.0, 1.0],\n",
|
144 |
| - " \n", |
145 |
| - " [ 1.0, 1.0, 1.0],\n", |
146 | 172 | " [-1.0, 1.0, 1.0],\n",
|
147 |
| - " [-1.0, -1.0, 1.0],\n", |
148 |
| - " ])" |
| 173 | + " ], dtype=np.float32),\n", |
| 174 | + " normalized=False)" |
149 | 175 | ]
|
150 | 176 | },
|
151 | 177 | {
|
|
154 | 180 | "metadata": {},
|
155 | 181 | "outputs": [],
|
156 | 182 | "source": [
|
157 |
| - "print(repr(geometry))" |
| 183 | + "# Index buffer\n", |
| 184 | + "index = BufferAttribute(\n", |
| 185 | + " array=np.array([\n", |
| 186 | + " [0, 1, 2],\n", |
| 187 | + " [2, 3, 0],\n", |
| 188 | + " ], dtype=np.uint16).ravel(),\n", |
| 189 | + " normalized=False)" |
158 | 190 | ]
|
159 | 191 | },
|
160 | 192 | {
|
|
163 | 195 | "metadata": {},
|
164 | 196 | "outputs": [],
|
165 | 197 | "source": [
|
166 |
| - "#\n", |
167 |
| - "# PlainBufferGeometry.from_geometry\n", |
168 |
| - "#" |
| 198 | + "geometry = PlainBufferGeometry(\n", |
| 199 | + " attributes={\n", |
| 200 | + " 'position': vertices,\n", |
| 201 | + " 'index': index,\n", |
| 202 | + " })" |
| 203 | + ] |
| 204 | + }, |
| 205 | + { |
| 206 | + "cell_type": "code", |
| 207 | + "execution_count": null, |
| 208 | + "metadata": {}, |
| 209 | + "outputs": [], |
| 210 | + "source": [ |
| 211 | + "geometry" |
| 212 | + ] |
| 213 | + }, |
| 214 | + { |
| 215 | + "cell_type": "markdown", |
| 216 | + "metadata": {}, |
| 217 | + "source": [ |
| 218 | + "### PlainBufferGeometry.from_geometry" |
169 | 219 | ]
|
170 | 220 | },
|
171 | 221 | {
|
|
0 commit comments