Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
2f6358dd
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2f6358dd
编写于
6月 17, 2021
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Clean up.
上级
4e0669ae
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
87 deletion
+66
-87
examples/js/loaders/NRRDLoader.js
examples/js/loaders/NRRDLoader.js
+21
-45
examples/js/misc/Volume.js
examples/js/misc/Volume.js
+10
-12
examples/js/misc/VolumeSlice.js
examples/js/misc/VolumeSlice.js
+2
-2
examples/jsm/loaders/NRRDLoader.js
examples/jsm/loaders/NRRDLoader.js
+23
-18
examples/jsm/misc/Volume.js
examples/jsm/misc/Volume.js
+8
-8
examples/jsm/misc/VolumeSlice.js
examples/jsm/misc/VolumeSlice.js
+2
-2
未找到文件。
examples/js/loaders/NRRDLoader.js
浏览文件 @
2f6358dd
...
...
@@ -359,80 +359,56 @@
volume
.
windowLow
=
min
;
volume
.
windowHigh
=
max
;
// get the image dimensions
// get the image dimensions
volume
.
dimensions
=
[
headerObject
.
sizes
[
0
],
headerObject
.
sizes
[
1
],
headerObject
.
sizes
[
2
]
];
volume
.
xLength
=
volume
.
dimensions
[
0
];
volume
.
yLength
=
volume
.
dimensions
[
1
];
volume
.
zLength
=
volume
.
dimensions
[
2
];
volume
.
zLength
=
volume
.
dimensions
[
2
];
// Identify axis order in the space-directions matrix from the header if possible.
// Identify axis order in the space-directions matrix from the header if possible.
if
(
headerObject
.
vectors
)
{
const
xIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
0
]
!==
0
);
const
yIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
1
]
!==
0
);
const
zIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
2
]
!==
0
);
if
(
headerObject
.
vectors
)
{
const
xIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
0
]
!==
0
);
const
yIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
1
]
!==
0
);
const
zIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
2
]
!==
0
);
const
axisOrder
=
[];
axisOrder
[
xIndex
]
=
'
x
'
;
axisOrder
[
yIndex
]
=
'
y
'
;
axisOrder
[
zIndex
]
=
'
z
'
;
axisOrder
[
xIndex
]
=
'
x
'
;
axisOrder
[
yIndex
]
=
'
y
'
;
axisOrder
[
zIndex
]
=
'
z
'
;
volume
.
axisOrder
=
axisOrder
;
}
else
{
volume
.
axisOrder
=
[
'
x
'
,
'
y
'
,
'
z
'
];
}
// spacing
}
else
{
volume
.
axisOrder
=
[
'
x
'
,
'
y
'
,
'
z
'
];
}
// spacing
const
spacingX
=
new
THREE
.
Vector3
().
fromArray
(
headerObject
.
vectors
[
0
]
).
length
();
const
spacingY
=
new
THREE
.
Vector3
().
fromArray
(
headerObject
.
vectors
[
1
]
).
length
();
const
spacingZ
=
new
THREE
.
Vector3
().
fromArray
(
headerObject
.
vectors
[
2
]
).
length
();
volume
.
spacing
=
[
spacingX
,
spacingY
,
spacingZ
];
volume
.
spacing
=
[
spacingX
,
spacingY
,
spacingZ
];
// Create IJKtoRAS matrix
// Create IJKtoRAS matrix
volume
.
matrix
=
new
THREE
.
Matrix4
();
const
transitionMatrix
=
new
THREE
.
Matrix4
();
if
(
headerObject
.
space
===
'
left-posterior-superior
'
)
{
transitionMatrix
.
set
(
-
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
transitionMatrix
.
set
(
-
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
}
else
if
(
headerObject
.
space
===
'
left-anterior-superior
'
)
{
transitionMatrix
.
set
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
);
transitionMatrix
.
set
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
);
}
if
(
!
headerObject
.
vectors
)
{
volume
.
matrix
.
set
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
volume
.
matrix
.
set
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
}
else
{
const
v
=
headerObject
.
vectors
;
const
ijk_to_transition
=
(
new
THREE
.
Matrix4
()
).
set
(
v
[
0
][
0
],
v
[
1
][
0
],
v
[
2
][
0
],
0
,
v
[
0
][
1
],
v
[
1
][
1
],
v
[
2
][
1
],
0
,
v
[
0
][
2
],
v
[
1
][
2
],
v
[
2
][
2
],
0
,
0
,
0
,
0
,
1
)
const
transition_to_ras
=
(
new
THREE
.
Matrix4
()).
multiplyMatrices
(
ijk_to_transition
,
transitionMatrix
);
const
ijk_to_transition
=
new
THREE
.
Matrix4
().
set
(
v
[
0
][
0
],
v
[
1
][
0
],
v
[
2
][
0
],
0
,
v
[
0
][
1
],
v
[
1
][
1
],
v
[
2
][
1
],
0
,
v
[
0
][
2
],
v
[
1
][
2
],
v
[
2
][
2
],
0
,
0
,
0
,
0
,
1
);
const
transition_to_ras
=
new
THREE
.
Matrix4
().
multiplyMatrices
(
ijk_to_transition
,
transitionMatrix
);
volume
.
matrix
=
transition_to_ras
;
}
...
...
examples/js/misc/Volume.js
浏览文件 @
2f6358dd
...
...
@@ -13,7 +13,7 @@
* @param {ArrayBuffer} arrayBuffer The buffer with volume data
*/
var
Volume
=
function
(
xLength
,
yLength
,
zLength
,
type
,
arrayBuffer
)
{
function
Volume
(
xLength
,
yLength
,
zLength
,
type
,
arrayBuffer
)
{
if
(
arguments
.
length
>
0
)
{
...
...
@@ -31,13 +31,11 @@
*/
this
.
zLength
=
Number
(
zLength
)
||
1
;
/**
* @member {Array<string>} The order of the Axis dictated by the NRRD header
*/
* @member {Array<string>} The order of the Axis dictated by the NRRD header
*/
this
.
axisOrder
=
[
'
x
'
,
'
y
'
,
'
z
'
];
/**
* @member {TypedArray} data Data of the volume
*/
...
...
@@ -209,7 +207,7 @@
* @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space
*/
}
;
}
Volume
.
prototype
=
{
constructor
:
Volume
,
...
...
@@ -313,8 +311,8 @@
axisInIJK
.
set
(
1
,
0
,
0
);
firstDirection
.
set
(
0
,
0
,
-
1
);
secondDirection
.
set
(
0
,
-
1
,
0
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
IJKIndex
=
new
THREE
.
Vector3
(
RASIndex
,
0
,
0
);
planeMatrix
.
multiply
(
new
THREE
.
Matrix4
().
makeRotationY
(
Math
.
PI
/
2
)
);
positionOffset
=
(
volume
.
RASDimensions
[
0
]
-
1
)
/
2
;
...
...
@@ -325,8 +323,8 @@
axisInIJK
.
set
(
0
,
1
,
0
);
firstDirection
.
set
(
1
,
0
,
0
);
secondDirection
.
set
(
0
,
0
,
1
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
IJKIndex
=
new
THREE
.
Vector3
(
0
,
RASIndex
,
0
);
planeMatrix
.
multiply
(
new
THREE
.
Matrix4
().
makeRotationX
(
-
Math
.
PI
/
2
)
);
positionOffset
=
(
volume
.
RASDimensions
[
1
]
-
1
)
/
2
;
...
...
@@ -338,8 +336,8 @@
axisInIJK
.
set
(
0
,
0
,
1
);
firstDirection
.
set
(
1
,
0
,
0
);
secondDirection
.
set
(
0
,
-
1
,
0
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
IJKIndex
=
new
THREE
.
Vector3
(
0
,
0
,
RASIndex
);
positionOffset
=
(
volume
.
RASDimensions
[
2
]
-
1
)
/
2
;
planeMatrix
.
setPosition
(
new
THREE
.
Vector3
(
0
,
0
,
RASIndex
-
positionOffset
)
);
...
...
examples/js/misc/VolumeSlice.js
浏览文件 @
2f6358dd
...
...
@@ -9,7 +9,7 @@
* @see Volume
*/
var
VolumeSlice
=
function
(
volume
,
index
,
axis
)
{
function
VolumeSlice
(
volume
,
index
,
axis
)
{
var
slice
=
this
;
/**
...
...
@@ -96,7 +96,7 @@
* @returns {Number} the index corresponding to the voxel in volume.data of the given position in the slice
*/
}
;
}
VolumeSlice
.
prototype
=
{
constructor
:
VolumeSlice
,
...
...
examples/jsm/loaders/NRRDLoader.js
浏览文件 @
2f6358dd
...
...
@@ -365,19 +365,22 @@ class NRRDLoader extends Loader {
volume
.
zLength
=
volume
.
dimensions
[
2
];
// Identify axis order in the space-directions matrix from the header if possible.
if
(
headerObject
.
vectors
)
{
const
xIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
0
]
!==
0
);
const
yIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
1
]
!==
0
);
const
zIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
2
]
!==
0
);
if
(
headerObject
.
vectors
)
{
const
xIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
0
]
!==
0
);
const
yIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
1
]
!==
0
);
const
zIndex
=
headerObject
.
vectors
.
findIndex
(
vector
=>
vector
[
2
]
!==
0
);
const
axisOrder
=
[];
axisOrder
[
xIndex
]
=
'
x
'
;
axisOrder
[
yIndex
]
=
'
y
'
;
axisOrder
[
zIndex
]
=
'
z
'
;
axisOrder
[
xIndex
]
=
'
x
'
;
axisOrder
[
yIndex
]
=
'
y
'
;
axisOrder
[
zIndex
]
=
'
z
'
;
volume
.
axisOrder
=
axisOrder
;
}
else
{
volume
.
axisOrder
=
[
'
x
'
,
'
y
'
,
'
z
'
];
}
else
{
volume
.
axisOrder
=
[
'
x
'
,
'
y
'
,
'
z
'
];
}
// spacing
...
...
@@ -396,17 +399,19 @@ class NRRDLoader extends Loader {
transitionMatrix
.
set
(
-
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
);
0
,
0
,
0
,
1
);
}
else
if
(
headerObject
.
space
===
'
left-anterior-superior
'
)
{
transitionMatrix
.
set
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
);
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
1
);
}
...
...
@@ -423,14 +428,14 @@ class NRRDLoader extends Loader {
const
v
=
headerObject
.
vectors
;
const
ijk_to_transition
=
(
new
Matrix4
()
).
set
(
const
ijk_to_transition
=
new
Matrix4
(
).
set
(
v
[
0
][
0
],
v
[
1
][
0
],
v
[
2
][
0
],
0
,
v
[
0
][
1
],
v
[
1
][
1
],
v
[
2
][
1
],
0
,
v
[
0
][
2
],
v
[
1
][
2
],
v
[
2
][
2
],
0
,
0
,
0
,
0
,
1
)
)
;
const
transition_to_ras
=
(
new
Matrix4
()
).
multiplyMatrices
(
ijk_to_transition
,
transitionMatrix
);
const
transition_to_ras
=
new
Matrix4
(
).
multiplyMatrices
(
ijk_to_transition
,
transitionMatrix
);
volume
.
matrix
=
transition_to_ras
;
...
...
@@ -438,7 +443,7 @@ class NRRDLoader extends Loader {
volume
.
inverseMatrix
=
new
Matrix4
();
volume
.
inverseMatrix
.
copy
(
volume
.
matrix
).
invert
();
volume
.
RASDimensions
=
(
new
Vector3
(
volume
.
xLength
,
volume
.
yLength
,
volume
.
zLength
)
).
applyMatrix4
(
volume
.
matrix
).
round
().
toArray
().
map
(
Math
.
abs
);
volume
.
RASDimensions
=
new
Vector3
(
volume
.
xLength
,
volume
.
yLength
,
volume
.
zLength
).
applyMatrix4
(
volume
.
matrix
).
round
().
toArray
().
map
(
Math
.
abs
);
// .. and set the default threshold
// only if the threshold was not already set
...
...
examples/jsm/misc/Volume.js
浏览文件 @
2f6358dd
...
...
@@ -17,7 +17,7 @@ import { VolumeSlice } from '../misc/VolumeSlice.js';
* @param {string} type The type of data (uint8, uint16, ...)
* @param {ArrayBuffer} arrayBuffer The buffer with volume data
*/
var
Volume
=
function
(
xLength
,
yLength
,
zLength
,
type
,
arrayBuffer
)
{
function
Volume
(
xLength
,
yLength
,
zLength
,
type
,
arrayBuffer
)
{
if
(
arguments
.
length
>
0
)
{
...
...
@@ -196,7 +196,7 @@ var Volume = function ( xLength, yLength, zLength, type, arrayBuffer ) {
* @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space
*/
}
;
}
Volume
.
prototype
=
{
...
...
@@ -304,8 +304,8 @@ Volume.prototype = {
axisInIJK
.
set
(
1
,
0
,
0
);
firstDirection
.
set
(
0
,
0
,
-
1
);
secondDirection
.
set
(
0
,
-
1
,
0
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
IJKIndex
=
new
Vector3
(
RASIndex
,
0
,
0
);
planeMatrix
.
multiply
(
(
new
Matrix4
()
).
makeRotationY
(
Math
.
PI
/
2
)
);
...
...
@@ -316,8 +316,8 @@ Volume.prototype = {
axisInIJK
.
set
(
0
,
1
,
0
);
firstDirection
.
set
(
1
,
0
,
0
);
secondDirection
.
set
(
0
,
0
,
1
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
z
'
)
];
IJKIndex
=
new
Vector3
(
0
,
RASIndex
,
0
);
planeMatrix
.
multiply
(
(
new
Matrix4
()
).
makeRotationX
(
-
Math
.
PI
/
2
)
);
...
...
@@ -329,8 +329,8 @@ Volume.prototype = {
axisInIJK
.
set
(
0
,
0
,
1
);
firstDirection
.
set
(
1
,
0
,
0
);
secondDirection
.
set
(
0
,
-
1
,
0
);
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
firstSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
x
'
)
];
secondSpacing
=
this
.
spacing
[
this
.
axisOrder
.
indexOf
(
'
y
'
)
];
IJKIndex
=
new
Vector3
(
0
,
0
,
RASIndex
);
positionOffset
=
(
volume
.
RASDimensions
[
2
]
-
1
)
/
2
;
...
...
examples/jsm/misc/VolumeSlice.js
浏览文件 @
2f6358dd
...
...
@@ -16,7 +16,7 @@ import {
* @param {string} [axis='z'] For now only 'x', 'y' or 'z' but later it will change to a normal vector
* @see Volume
*/
var
VolumeSlice
=
function
(
volume
,
index
,
axis
)
{
function
VolumeSlice
(
volume
,
index
,
axis
)
{
var
slice
=
this
;
/**
...
...
@@ -95,7 +95,7 @@ var VolumeSlice = function ( volume, index, axis ) {
*/
}
;
}
VolumeSlice
.
prototype
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录