This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getInstanceMatrix(position, radius, spacing, objMap){ | |
/* | |
const matrices = useMemo(() => { | |
return getInstanceMatrix([0, 0, 0], 10, 1, { | |
minNoise: -1, | |
maxNoise: 1, | |
getNoise: (x, y, z) => { return noise.GetNoise(x, y, z) } | |
}); | |
}, [noise]); // Add any other dependencies here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import platform | |
# Path to the Blender executable | |
if platform.system() == "Windows": | |
blender_executable_path = "C:\\Program Files\\Blender Foundation\\Blender\\blender.exe" | |
elif platform.system() == "Linux": | |
blender_executable_path = "/usr/bin/blender" | |
else: | |
blender_executable_path = "/Applications/Blender.app/Contents/MacOS/Blender" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
import importlib.util | |
# RUN THIS INSIDE BLENDER SCRIPTING TAB | |
def addPip(strLibrary, reinstall=False): | |
if importlib.util.find_spec(strLibrary) is None: | |
# Ensure pip is installed | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all these hooks MUST be inside the react components | |
const cameraState = useContext(SceneContext); | |
useFrame(state => { | |
const vectorGo = new THREE.Vector3(); | |
vectorGo.set(...cameraState.position); | |
const vector = new THREE.Vector3(); | |
const vector2 = new THREE.Vector3(); | |
vector.set(...cameraState.target); | |
vector2.set(...cameraState.target); | |
// const intDistance = 10.75; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isClearPath(vert1, vert2, depsgraph): | |
# Test if there are any obstructions from vert 1 to vert 2 until it reaches obj2 | |
# test for given clearance around the ray traced path with 6 parallel line a given distance of clearnace away from original path t test fo | |
# isClear = isClearPath(vert1, vert2, depsgraph) | |
# Calculate the direction vector from vert1 to vert2 | |
direction_vector = vert2 - vert1 | |
# Normalize the direction vector | |
direction = direction_vector.normalized() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def objTo2DProfile(obj, strName=None, strPosition="ORIGIN"): | |
if strName == None: | |
strName = f'{obj.name}_profile' | |
arrVerts = [] | |
arrPolyVerts = [] | |
for vert in obj.data.vertices: | |
arrVerts.append((vert.co.x, vert.co.y)) | |
arrVertIndices = mathutils.geometry.convex_hull_2d(arrVerts) | |
for intVert in arrVertIndices: | |
arrPolyVerts.append([arrVerts[intVert][0], arrVerts[intVert][1], 0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def diceObj(obj): | |
bm = getBMesh(obj) | |
# add one for both ends of a row because we want to start from the center | |
# hold all the planes to bisect with as (location), (normal) | |
arrPlanes = [] | |
# get each X and Y from | |
# get verts by faces so we have a normal | |
for face in bm.faces: | |
for v in face.verts: | |
arrPlanes.append( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def faceTheWorld(obj, strMode="EDIT"): | |
# Thanks to JohnKaz and Kritskiy on BPY Discord for this function, looks simple, but not easy to figure out! | |
mw = obj.matrix_world.copy() | |
bm = bmesh.new() | |
if strMode == 'OBJECT': | |
bm.from_mesh(obj.data) | |
else: | |
bm = bmesh.from_edit_mesh(obj.data) | |
face = next(iter(face for face in bm.faces if face.select), None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def batchTransform(arrBatch, context=None, update_view=False): | |
# { | |
# object: string name_full, | |
# action: string = SCALE | ROTATE | ORIGIN | MOVE, | |
# value: (x,y,z), or string for parent or collection name | |
# mode: LOCAL=relative or adding, WORLD= world coordinates or setting value | |
# } | |
# return an array of issues, or empty array if all good. | |
arrErrors=[] | |
if context == None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import math | |
def diceObj(obj, intSize = 0.5): | |
arrDimensions = obj.dimensions | |
# add one for both ends of a row because we want to start from the center | |
intRowsX = math.floor((arrDimensions[0]/intSize) + 1) | |
intRowsY = math.floor((arrDimensions[1]/intSize) + 1) | |
bm = bmesh.new() | |
bm.from_mesh(obj.data) |
NewerOlder